JezK
Edit File: newasn.php
<?php include("app/checkSession.php"); include("header.php"); // include("app/adminObj.php"); $optionData=''; // print_r($_SESSION); $quationIds=$customerObj->getQuationList($_SESSION['customer_user_id']); $selectedId = isset($_REQUEST['q_id']) ? $_REQUEST['q_id']: ""; $quationId=$quationIds ? $quationIds : []; foreach($quationId as $id){ $selected = ""; if($selectedId == $id['quotation_id']) { $selected = "selected"; } $optionData.='<option value='.$id['quotation_id'].' '.$selected .'>'.$id['quotation_id'].'</option>'; } ?> <div class="container px-md-5 px-0 "> <a href="javascript:history.go(-1)"><img src="images/back_main.png" class="pb-3"></a> <h4 class="mb-4"><?php echo $lang['NEW_ASN'];?></h4> <div class="containercontent m-2"> <form action="./app/newasn-app.php" method="POST"> <input type="hidden" value="<?php echo $_SESSION['customer_user_id']?>" name="userId"> <input type="hidden" value="" name="warehouseid" id="warehouseId"> <input type="hidden" value="" name="warehouseAdminid" id="warehouseAdminid"> <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="currency" name="quotationId" class="form-control frm-input" onChange="return selectQuationId(this.value)"> <option value=""><?php echo $lang['SELECT'];?></option> <!-- <option value="1">qutoation</option> --> <?= $optionData;?> </select> <div class="error quote_id_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="Request type" 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="Customer" 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="customer_type" placeholder="customertype" name="customerTypeText" readonly> <input type="hidden" class="form-control" id="customertypeId" placeholder="Customer type" 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="Warehouse name" name="warehouseName" readonly> <div class="error warehouse_name_error"></div> </div> <div class="form-group col-md-6 col-lg-3 col-sm-12"> <label for="inputEmail4"><?php echo $lang['WAREHOUSE_TYPE'];?></label> <input type="text" class="form-control" id="warehouseType" placeholder="Warehouse Type" 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> <input type="text" class="form-control" id="date" placeholder="dd-mm-yyyy" name="date"> <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> <input type="time" class="form-control" id="time" name="time" placeholder="10:00 AM"> <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="Quote value" name="quoteValue" readonly> <span id="currencyValue"></span> <div class="error quote_error"></div> </div> </div> <div class="container pl-5 pr-5 pt-3"> <p class="text-dark"><strong><?php echo $lang['ADD_ITEM_DETAILS'];?></strong></p> </div> <div class="warehouse_boxshadow table-responsive container py-5"> <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> </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 mr-0 mt-3 mb-2" onclick="return newasnValidations();"><?php echo $lang['SAVE'];?></button> </form> </div> </div> <?php include("footer.php"); ?> <link rel="stylesheet" href="css/bootstrap-datetimepicker.min.css" type="text/css"> <script type="text/javascript" src="js/date_time/nl.js"></script> <style> .form-control::placeholder{ color:#bbbbbb; } .newRow_add tr td { padding: 0px !important; } .newRow_add tr td input{ width:100% !important;border:none;background:#eaeffa;padding: 10px;border-bottom: 1px solid #3663c88c; } button#addRow ,button#addRowSave{ background: #3663c8; border: none; padding: 5px 15px; color: #fff; font-size: 14px ; font-weight: bold; } .invoices_page_div input { width: 100%; border: 1px solid #ced4da; border-radius: 5px; padding: 0px 5px; } .table-bordered td, .table-bordered th { border: 1px solid grey; } .newRow_add tbody tr:nth-child(even) input { background: #ffffff; } .btn-color { opacity: 0.5; } .currencytype { position: absolute; right: 15px; bottom: 0px; border: 1px solid #ced4da; padding: 6px; color: #2c60d0; font-weight: bold; background-color: #e9ecef; border-radius: 4px; cursor: auto; } .value { width: 75%; } span.expectedValue { position: absolute; right: 16px; bottom: 0px; border: 1px solid #e9ecef; padding: 6px; background-color: white; } table.table.table-bordered.table_body.newRow_add input { text-align: center; } </style> <script type="text/javascript"> $ = jQuery; $(document).ready(function() { $("#date").datetimepicker({ format: 'YYYY-MM-DD', minDate:new Date() }) id1=document.getElementById("currency").value; jQuery.ajax({ type:'POST', url:'ajax.php', data:({action:'getQuotationDetail',quoteId:id1}), success:function(data){ data1=JSON.parse(data); if(data1.asn_status==1){ alert(" Already ASN Request Sent To This Quotation ID ") }else if(data1.asn_status==0){ document.getElementById('customer').value=data1.first_name; document.getElementById('warehouseName').value=data1.warehouse_name; document.getElementById('quotationvalue').value=data1.admin_expected_rate; if(data1.warehouse_packageid==2){ document.getElementById('warehouseType').value="<?php echo $lang['SILVER'];?>"; } if(data1.role_id==1){ document.getElementById('customer_type').value="<?php echo $lang['WAREHOUSE_ADMIN'];?>"; } else if(data1.role_id==2){ document.getElementById('customer_type').value='<?php echo $lang['WAREHOUSE_SUB_ADMIN'];?>'; } else if(data1.role_id==3){ document.getElementById('customer_type').value='<?php echo $lang['INDIVIDUAL_USER'];?>'; } else if(data1.role_id==4){ document.getElementById('customer_type').value='<?php echo $lang['BUSINESS_USER'];?>'; } document.getElementById('warehouseId').value=data1.warehouse_id; document.getElementById('customertypeId').value=data1.role_id; document.getElementById('warehouseAdminid').value=data1.whadmin_id; // alert(data1.warehouse_request_type) if(data1.warehouse_request_type==0){ document.getElementById('requestType').value="<?php echo $lang['REQUEST_QUOTE'];?>" ; } if(data1.warehouse_request_type==1){ document.getElementById('requestType').value="<?php echo $lang['ONLINE_BOOKING'];?>" ; } if(data1.currency!=''){ document.getElementById('currencyValue').innerHTML=data1.currency; $('#currencyValue').addClass('currencytype') }else{ document.getElementById('currencyValue').innerHTML=""; } document.getElementById('currencyLabel').innerHTML="<?php echo $lang['COST'];?> "+" "+"("+data1.currency+")"; } // $().addClass('') } }) // .on('dp.change',function(e){ // date = moment($('#date').val(), 'MM-DD-YYYY') // $('#date').data("DateTimePicker").minDate(date); // }); } ); function selectQuationId(id){ jQuery.ajax({ type:'POST', url:'ajax.php', data:({action:'getQuotationDetail',quoteId:id}), success:function(data){ data1=JSON.parse(data); if(data1.asn_status==1){ alert(" Already ASN Request Sent To This Quotation ID ") }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; if(data1.warehouse_packageid==2){ document.getElementById('warehouseType').value="<?php echo $lang['SILVER'];?>"; } if(data1.role_id==1){ document.getElementById('customer_type').value="<?php echo $lang['WAREHOUSE_ADMIN'];?>"; } else if(data1.role_id==2){ document.getElementById('customer_type').value='<?php echo $lang['WAREHOUSE_SUB_ADMIN'];?>'; } else if(data1.role_id==3){ document.getElementById('customer_type').value='<?php echo $lang['INDIVIDUAL_USER'];?>'; } else if(data1.role_id==4){ document.getElementById('customer_type').value='<?php echo $lang['BUSINESS_USER'];?>'; } document.getElementById('warehouseId').value=data1.warehouse_id; document.getElementById('customertypeId').value=data1.role_id; document.getElementById('warehouseAdminid').value=data1.whadmin_id; if(data1.currency!=''){ document.getElementById('currencyValue').innerHTML=data1.currency; }else{ document.getElementById('currencyValue').innerHTML=""; } document.getElementById('currencyLabel').innerHTML="<?php echo $lang['COST'];?> "+" "+"("+data1.currency+")"; // alert(data1.warehouse_request_type) if(data1.warehouse_request_type==0){ document.getElementById('requestType').value="<?php echo $lang['REQUEST_QUOTE'];?>" ; } if(data1.warehouse_request_type==1){ document.getElementById('requestType').value="<?php echo $lang['ONLINE_BOOKING'];?>" ; } } } }) $('#currencyValue').addClass('currencytype') } $('.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('* <?php echo $lang['PLEASE_FILL_ALL_THE_REQUIRED_FIELDS']; ?>'); // $('#itemcode').focus(); ///return false; } }); function newasnValidations(){ var numregex = /^[0-9\s]*$/; let Quote_id =document.getElementById('currency').value; let request_type=document.getElementById('requestType').value; let customer=document.getElementById('customer').value; let customer_type=document.getElementById('customer_type').value; let warehouseName=document.getElementById('warehouseName').value; let warehouseType=document.getElementById('warehouseType').value; let date=document.getElementById('date').value; let time=document.getElementById('time').value; let quotation_value=document.getElementById('quotationvalue').value; // 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; $('.error').html(''); if(Quote_id==''){ $('.quote_id_error').html('<?php echo $lang['SELECT_QUOTE_ID']; ?>'); $('#Quote_id').focus(); return false; } else if(request_type=='' ){ // alert('hello') $('.request_type_error').html('<?php echo $lang['SELECT_REQUEST_TYPE']; ?>'); $('#request_type').focus() return false; } else if(customer==''){ $('.customer_error').html(' <?php echo $lang['CUSTOMER_REQUIRED']; ?> '); $('#customer').focus(); return false; } else if(customer_type ==''){ $('.customer_type_error').html(' <?php echo $lang['CUSTOMER_TYPE_REQUIRED']; ?>'); $('#customer_type').focus() return false; } else if(warehouseName==''){ $('.warehouse_name_error').html('<?php echo $lang['WAREHOUSE_NAME_REQUIRED']; ?>'); $('#warehouseName').focus(); return false; } else if(warehouseType==''){ $('.warehouse_type_error').html('<?php echo $lang['WAREHOUSE_TYPE_REQUIRED']; ?>'); $('#warehouseType').focus(); return false; } else if(date==''){ $('.Date_error').html('<?php echo $lang['DATE_REQUIRED']; ?>'); $('#date').focus(); return false; } else if(time==''){ $('.Time_error').html('<?php echo $lang['TIME_REQUIRED']; ?>'); $('#time').focus(); return false; } else if(quotation_value==''){ $('.quote_error').html('<?php echo $lang['QUOTATION_VALUE_REQUIRED']; ?>'); $('#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[]') // alert(itemcodeval.length) 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_REF_NUMBER']; ?>'); costval[x].focus(); return false; } } } function checkPhone(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() } </script>