JezK
Edit File: createnewasn.php
<?php include_once("./app/checkSession.php"); include("header.php"); // include("./app/adminObj.php"); $optionData=''; // print_r($_SESSION); $quationIds=$wareHouseAdminObj->getQuationList($_SESSION['company_id']); // print_r($quationIds); foreach($quationIds as $id){ $selected=""; if(isset($_REQUEST['q_id']) && $_REQUEST['q_id'] == $id['quotation_id']) { $selected="selected"; } $optionData.='<option value="'.$id['quotation_id'].'" '.$selected.'>'.$id['quotation_id'].'</option>'; } ?> <link rel="stylesheet" href="css/editcontact.css"> <a href="javascript:history.go(-1)" class="ml-5"><img src="images/back_main.png" class="pb-3"></a> <div class="container px-md-5 px-3"> <h4><?php echo $lang['NEW_ASN'];?></h4> <div class="containercontent"> <form action="./app/addAsn-app.php" method="POST"> <input type="hidden" value="" name="userId" id="userId"> <input type="hidden" value="<?php echo $_SESSION['user_id']?>" name="warehouseAdminId"> <input type="hidden" name="warehouseId" id="warehouseid"> <div class="form-row "> <div class="form-group col-md-6 col-lg-3 col-sm-12 "> <label for="quote"><?php echo $lang['QUOTE_ID'];?></label> <select id="quoteId" name="quotationId" class="form-control frm-input" onChange="return selectQuationId(this.value)"> <option value=""><?php echo $lang['SELECT'];?></option> <?= $optionData;?> </select> <div class="error qutationid_error"></div> </div> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="inputEmail4"><?php echo $lang['REQUEST_TYPE'];?></label> <input type="text" class="form-control" id="requestType" placeholder="" name="requestType" readonly> <div class="error request_type_error"></div> </div> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="customer"><?php echo $lang['CUSTOMER_NAME'];?></label> <input type="text" class="form-control" id="customer" placeholder="" name="customer" readonly> <div class="error customer_error"></div> </div> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="custometype"><?php echo $lang['CUSTOMER_TYPE'];?></label> <input type="text" class="form-control" id="customertypeText" placeholder="" name="customerTypeText" readonly> <input type="hidden" class="form-control" id="customertypeId" placeholder="customertype" name="customerTypeId"> <div class="error customer_type_error"></div> </div> </div> <div class="form-row"> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="quote"><?php echo $lang['WAREHOUSE_NAME'];?></label> <input type="text" class="form-control" id="warehouseName" placeholder="" name="warehouseName" readonly> <div class="error warehouse_error"></div> </div> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="inputEmail4"><?php echo $lang['WAREHOUSE_TYPES'];?></label> <input type="text" class="form-control" id="warehouseType" placeholder="" name="warehouseType" readonly> <div class="error warehouse_type_error"></div> </div> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="date"><?php echo $lang['DATE'];?></label> <div class='input-group1 date d-flex' id='datetimepicker1'> <input type="text" class="form-control datepicker " id="date" placeholder="" name="date" /> <span class="input-group-addon right-0"> <span class="fa fa-calendar"></span> </span> </div> <div class="error date_error"></div> </div> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="time"><?php echo $lang['TIME'];?></label> <div class='input-group1 date d-flex' id='datetimepicker1'> <input type="text" class="form-control timepicker" id="time" name="time" placeholder=""> <span class="input-group-addon right-0"> <span class="fa fa-clock-o"></span> </span> </div> <div class="error time_error"></div> </div> </div> <div class="form-row"> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="quote"><?php echo $lang['TOTAL_VALUE_FOR_QUOTATION'];?></label> <input type="text" class="form-control Value" id="quotationvalue" placeholder="" name="quoteValue"> <span id="expectedValue"></span> <div class="error quote_value_error"></div> </div> </div> <div class="container pl-0 pr-5 pt-3"> <p class="text-dark"><strong><?php echo $lang['ADD_ITEM_DETAILS'];?></strong></p> </div> <div class="warehouse_boxshadow container py-5 table-responsive"> <table class="table table-bordered table_body newRow_add"> <thead class="theadcolor"> <tr> <th><?php echo $lang['ITEM_CODE'];?></th> <th><?php echo $lang['ITEM_DESCRIPTION'];?></th> <th><?php echo $lang['QUANTITY'];?></th> <th><?php echo $lang['REFERENCE_NUMBER'];?></th> <th id="currencyLabel"><?php echo $lang['COST'];?></th> <th><?php echo $lang['PALLET_NO'];?></th> <!-- <th>Delete</th> --> </tr> </thead> <tbody> <tr> <td><input type="text" id="itemcode" name="itemcode[]" ></td> <td><input type="text" id="item_desc" name="item_desc[]" ></td> <td><input type="text" id="qty" name="qty[]" onkeypress="return checkPhone(event)"></td> <td><input type="text" id="ref_number" name="ref_number[]"></td> <td><input type="text" id="cost" name="cost[]" onkeypress="return checkPhone(event)"></td> <td><input type="text" id="pallet_no" name="pallet_no[]"></td> </tr> </tbody> </table> <div class="error rowadd_error"></div> <div class="error itemcode_error"></div> <div class="error item_desc_error"></div> <div class="error qty_error"></div> <div class="error ref_number_error"></div> <div class="error cost_error"></div> <div class="error pallet_no_error"></div> <button id="addRow" disabled class="buttonDisable btn-color"><?php echo $lang['ADD'];?></button> </div> <button id="addRowSave" type="submit" name="saveAsn" class="float-right mt-3" onclick="return createNewAsnValidation()"><?php echo $lang['SAVE'];?></button> </form> </div> </div> <?php include("footer.php"); ?> <script> var defaults_time = { calendarWeeks: true, showClear: true, showClose: true, allowInputToggle: true, useCurrent: false, ignoreReadonly: true, //minDate: new Date(), toolbarPlacement: 'top', locale: 'nl', icons: { time: 'fa fa-clock-o', date: 'fa fa-calendar', up: 'fa fa-angle-up', down: 'fa fa-angle-down', previous: 'fa fa-angle-left', next: 'fa fa-angle-right', today: 'fa fa-dot-circle-o', clear: 'fa fa-trash', close: 'fa fa-times' } }; (function($){ var optionsDate = $.extend({}, {format:'YYYY-MM-DD'},{minDate:new Date()}); $(document).ready(function(){ $('#datepicker').datetimepicker(optionsDate); $('.datepicker').datetimepicker(optionsDate); }); })(jQuery); $(document).ready(function(){ var optionsTime = $.extend({}, defaults_time, {format:'HH:mm'}); $('.timepicker').datetimepicker(optionsTime); }); </script> <script> function phoneNumberValidation(e){ // alert(e) var key = e.keyCode || e.charCode; if(key == 13 || key == 43 || (key >= 48 && key <= 57) || key == 8 || key == 46) { return true; } else { return false; } // if() } function selectQuationId(id){ jQuery.ajax({ type:'POST', url:'../ajax.php', data:({action:'getQuotationDetail',quoteId:id}), success:function(data){ data1=JSON.parse(data); // alert(data1.warehouse_id) // console.log(data1,'data') if(data1.asn_status==1){ var msg='<?php echo $lang['ALREADY_ASN_REQUEST_SENT_TO_THIS_QUOTATION_ID']; ?>'; alert(msg) }else if(data1.asn_status==0){ document.getElementById('customer').value=data1.first_name +' '+ data1.last_name; document.getElementById('warehouseName').value=data1.warehouse_name; document.getElementById('quotationvalue').value=data1.admin_expected_rate ; document.getElementById('userId').value=data1.user_id ; document.getElementById('warehouseid').value=data1.warehouse_id ; document.getElementById('customertypeId').value=data1.role_id; if(data1.warehouse_request_type==0){ document.getElementById('requestType').value="<?php echo $lang['REQUEST_QUOTE'];?>" ; } else if(data1.warehouse_request_type==1){ document.getElementById('requestType').value="<?php echo $lang['ONLINE_BOOKING'];?>" ; } if(data1.warehouse_packageid==2){ document.getElementById('warehouseType').value="<?php echo $lang['SILVER'];?>"; } if(data1.role_id==1){ document.getElementById('customertypeText').value="<?php echo $lang['WAREHOUSE_ADMIN'];?>"; } else if(data1.role_id==2){ document.getElementById('customertypeText').value='<?php echo $lang['WAREHOUSE_SUB_ADMIN'];?>'; } else if(data1.role_id==3){ document.getElementById('customertypeText').value='<?php echo $lang['INDIVIDUAL_USER'];?>'; } else if(data1.role_id==4){ document.getElementById('customertypeText').value='<?php echo $lang['BUSINESS_USER'];?>'; } if(data1.currency!=''){ document.getElementById('expectedValue').innerHTML=data1.currency; }else{ document.getElementById('expectedValue').innerHTML=""; } document.getElementById('currencyLabel').innerHTML="<?php echo $lang['COST'];?> "+" "+"("+data1.currency+")"; } } }) $('#expectedValue').addClass('currencyType1') } $('.newRow_add tbody input').change(function(event){ var len=0; $(".newRow_add tbody input").each(function(){ if(this.value != ""){ len++; } if(len==5){ $("#addRow").removeAttr("disabled"); $("#addRow").removeClass("btn-color"); } }); }) var counter = 0; $ = jQuery; $('#addRow').click(function(event){ event.preventDefault(); $('.error').html(''); var valid = 0; $(".newRow_add tbody input").each(function(){ if(this.value == ""){ valid++; } }) if(valid == 0){ counter++; var newRow = $('<tr id='+counter+'><td><input type="text" id="itemcode'+counter+'" name="itemcode[]"/></td><td><input type="text" id="item_desc'+counter+'" name="item_desc[]"/></td><td><input type="text" id="qty'+counter+'" name="qty[]" onkeypress="return checkPhone(event)"/></td><td><input type="text" id="ref_number'+counter+'" name="ref_number[]"/></td><td><input type="text" id="cost[]" name="cost[]" onkeypress="return checkPhone(event)"/></td><td><input type="text" id="pallet_no'+counter+'" name="pallet_no[]"/></td></tr>'); jQuery('table.newRow_add').append(newRow); } else{ $('.rowadd_error').html('*Please Fill all the required fields'); $('#itemcode').focus(); ///return false; } }); function createNewAsnValidation(){ var numregex = /^[0-9\s]*$/; // let itemcodeval=document.getElementsByName('itemcode[]'); // alert(itemcodeval); let Quote_id =document.getElementById('quoteId').value let warehouseName= document.getElementById('warehouseName').value let customer_name= document.getElementById('customer').value let quotationValue= document.getElementById('quotationvalue').value // let email= document.getElementById('warehouseid').value; // let city=document.getElementById('customertypeId').value; let requestType=document.getElementById('requestType').value; let warehouseType=document.getElementById('warehouseType').value let customerType=document.getElementById('customertypeText').value let date=document.getElementById('date').value let time=document.getElementById('time').value // alert(date) // alert(time) // alert(total_days); let itemcode=document.getElementById('itemcode').value; let item_desc=document.getElementById('item_desc').value; let qty=document.getElementById('qty').value; let ref_number=document.getElementById('ref_number').value; let cost=document.getElementById('cost').value; let pallet_no=document.getElementById('pallet_no').value; // let row_val=document.getElementById('row_val').value; // let rack=document.getElementById('rack').value; // let pin=document.getElementById('pin').value; $('.error').html(''); if(Quote_id==''){ $('.qutationid_error').html('<?php echo $lang['SELECT_QUOTATION_ID']; ?>'); $('#quoteId').focus(); return false; } else if(requestType=='' ){ // alert('hello') $('.request_type_error').html('<?php echo $lang['SELECT_REQUEST_TYPE']; ?>'); $('#requestType').focus() return false; } else if(customer_name==''){ $('.customer_error').html('<?php echo $lang['CUSTOMER_NAME_REQUIRED']; ?>'); $('#customer').focus(); return false; } else if(warehouseName==''){ $('.warehouse_error').html('<?php echo $lang['WAREHOUSE_NAME_REQUIRED']; ?>'); $('#warehouseName').focus(); return false; } else if(customerType==''){ $('.customer_type_error').html('<?php echo $lang['CUSTOMER_TYPE_REQUIRED']; ?>'); $('#customertypeText').focus(); return false; }else if(warehouseType==''){ $('.warehouse_type_error').html('<?php echo $lang['WAREHOUSE_TYPE_REQUIRED']; ?>'); $('#warehouseType').focus(); return false; } else if(quotationValue==''){ $('.quote_value_error').html('<?php echo $lang['QUOTATION_VALUE_REQUIRED']; ?>'); $('#quotationvalue').focus(); return false; } else if(date==''){ $('.date_error').html('<?php echo $lang['PLEASE_ENTER_DATE']; ?>'); $('#date').focus(); return false; } else if(time==''){ $('.time_error').html('<?php echo $lang['PLEASE_ENTER_TIME']; ?>'); $('#time').focus(); return false; } else if(itemcode==''){ $('.itemcode_error').html('<?php echo $lang['PLEASE_ENTER_ITEMCODE']; ?>'); $('#itemcode').focus(); return false; } else if(item_desc==''){ $('.item_desc_error').html('<?php echo $lang['PLEASE_ENTER_ITEM_DESC']; ?>'); $('#item_desc').focus(); return false; } else if(qty==''){ $('.qty_error').html('<?php echo $lang['PLEASE_ENTER_QTY']; ?>'); $('#qty').focus(); return false; } else if(!numregex.test(qty)){ $('.qty_error').html('<?php echo $lang['PLEASE_ENTER_NUMERIC_VALUE']; ?>'); $('#qty').focus(); return false; } else if(ref_number==''){ $('.ref_number_error').html('<?php echo $lang['PLEASE_ENTER_REF_NUMBER']; ?>'); $('#ref_number').focus(); return false; } else if(cost==''){ $('.cost_error').html('<?php echo $lang['PLEASE_ENTER_COST']; ?>'); $('#cost').focus(); return false; } else if(!numregex.test(cost)){ $('.cost_error').html('<?php echo $lang['PLEASE_ENTER_NUMERIC_VALUE']; ?>'); $('#cost').focus(); return false; } // else if(pallet_no==''){ // $('.pallet_no_error').html('please enter pallet_no'); // $('#pallet_no').focus(); // return false; // }else if(!numregex.test(pallet_no)){ // $('.pallet_no_error').html('please enter numeric value'); // $('#pallet_no').focus(); // return false; // } let itemcodeval=document.getElementsByName('itemcode[]') let item_descval=document.getElementsByName('item_desc[]') let qtyval=document.getElementsByName('qty[]') let ref_numberval=document.getElementsByName('ref_number[]') let costval=document.getElementsByName('cost[]') let pallet_noval=document.getElementsByName('pallet_no[]') for(x=0 ;x< itemcodeval.length ; x++) { if(itemcodeval[x].value == '' || itemcodeval[x].value == '0') { $(".itemcode_error").html('* <?php echo $lang['PLEASE_ENTER_ITEMCODE']; ?>'); itemcodeval[x].focus(); return false; } else if(item_descval[x].value == '' || item_descval[x].value == '0') { $(".item_desc_error").html('* <?php echo $lang['PLEASE_ENTER_ITEM_DESC']; ?>'); item_descval[x].focus(); return false; } else if(qtyval[x].value == '' || qtyval[x].value == '0') { $(".qty_error").html('* <?php echo $lang['PLEASE_ENTER_QTY']; ?>'); qtyval[x].focus(); return false; } else if(!numregex.test(qtyval[x].value)){ $('.qty_error').html('<?php echo $lang['PLEASE_ENTER_NUMERIC_VALUE']; ?>'); qtyval[x].focus(); return false; } else if(ref_numberval[x].value == '' || ref_numberval[x].value == '0') { $(".ref_number_error").html('* <?php echo $lang['PLEASE_ENTER_REF_NUMBER']; ?>'); ref_numberval[x].focus(); return false; } else if(costval[x].value == '' || costval[x].value == '0') { $(".cost_error").html('* <?php echo $lang['PLEASE_ENTER_COST']; ?>'); costval[x].focus(); return false; } else if(!numregex.test(costval[x].value)){ $('.cost_error').html('<?php echo $lang['PLEASE_ENTER_NUMERIC_VALUE']; ?>'); costval[x].focus(); return false; } } } </script> <style> .newRow_add tr td { padding: 10px !important; font-size:15px; } .newRow_add tr td input{ width:100% !important;border:none;background:#eaeffa;padding: 0px;border-bottom: 1px solid #3663c88c; text-align: center; } button#addRow ,button#addRowSave{ background: #3663c8; border: none; padding: 5px 15px; color: #fff; } .invoices_page_div input { width: 100%; border: 1px solid #3663c8; border-radius: 5px; padding: 0px 5px; } .btn-color { opacity: 0.5; } input.Value { width: 75%; } /* span.expectedValue { position: absolute; right: 16px; bottom: 0px; border: 1px solid #e9ecef; padding: 6px; background-color: white; } */ .currencyType1 { position: absolute; margin-left: 8px !important; color: #2c60d0; font-weight: bold; right: 10px; bottom: 0px; padding: 6px; border: 1px solid #ced4da; background-color: white; } </style> <!-- <script type="text/javascript" src="../js/jquery-3.5.1.min.js"></script> --> <script type="text/javascript" src="js/validations.js"></script> <script type="text/javascript" src="../js/validations.js"></script> <script> var quotationId = "<?php echo isset($_REQUEST['q_id']) ? $_REQUEST['q_id'] : ''; ?>"; if(quotationId && quotationId!="") { selectQuationId(quotationId) } </script>