File manager - Edit - /home/autoph/public_html/connect/home/PRF/PRF_AddNewPRFItemsAndHeaders.php
Back
<?php include 'core/init.php'; //$connect_error = 'Sorry, we\'re experiencing connection problem. Please try again later... Thank you!'; //mysql_connect('localhost','root','aee1024') or die ($connect_error); //mysql_select_db('db_vts') or die($connect_error); //error_reporting(1); 193 * 1067 * 215 $prfDate = date_create() ->format("Y-m-d"); $prfTime = date('H:i:s'); $myDate = date_create() ->format("Y-m-d"); $myUID = $user_data['u_id']; if(isset($_POST['done'])){ $uReferenceID = mysql_escape_string($_POST['uReferenceID']); $prfCompanySelected = mysql_escape_string($_POST['prfCompanySelected']); $myDealerList = mysql_escape_string($_POST['myDealerList']); $prfCategorySelected = mysql_escape_string($_POST['prfCategorySelected']); $CategorySubItem = mysql_escape_string($_POST['CategorySubItem']); $PurposeOfReqeust = mysql_escape_string($_POST['PurposeOfReqeust']); $ReqDateNeeded = mysql_escape_string($_POST['DateNeeded']); $DateNeeded = date("Y-m-d", strtotime($ReqDateNeeded)); $txtAddItemDesc = mysql_escape_string($_POST['txtAddItemDesc']); $prfApprovingHead = mysql_escape_string($_POST['prfApprovingHead']); $txtAddItemQty = mysql_escape_string($_POST['txtAddItemQty']); $addCompID = mysql_escape_string($_POST['addCompID']); $UnitOfMeasure = mysql_escape_string($_POST['UnitOfMeasure']); $itemCategoryClean = mysql_escape_string($_POST['itemCategory']); $itemCategory = str_replace(' ', '', $itemCategoryClean); //check if item class do exist in the database. If not exist insert this class as new $chkIFitemCategoryExist = mysql_result(mysql_query("SELECT COUNT(id) FROM `prf_item_category` WHERE `item_category`='$itemCategory'"),0); if($chkIFitemCategoryExist == 0 ){ mysql_query("INSERT INTO prf_item_category(item_category,asset_cat) VALUES('{$itemCategory}','{$prfCategorySelected}')"); } $itemCategoryID = mysql_result(mysql_query("SELECT `id` FROM `prf_item_category` WHERE `item_category`='$itemCategory'"),0); //get Company Approving Officer $getCompOfficer = mysql_result(mysql_query("SELECT `approver_id` FROM `prf_company_asset_approver` WHERE `comp_id`='$prfCompanySelected' AND `expense_item_id`='$CategorySubItem'"),0); //get execom approver $getGMApprover = mysql_result(mysql_query("SELECT `company_GM_id` FROM `vts_company` WHERE `comp_id`='$prfCompanySelected'"),0); $chkIfExist = mysql_result(mysql_query("SELECT COUNT(id) FROM `prf_request_hdr` WHERE `reference_code`='$uReferenceID'"),0); if($chkIfExist == 0){ //CREATE HEADER AND ADD FIRST ITEM IN THE DETL TABLE //PRF HEADER mysql_query("INSERT INTO prf_request_hdr(reference_code,comp_id,deal_id,category_id,sub_category_id,request_by,dept_head_id,approving_admin_id,approving_GM_id,current_status,date_needed,date_created,time_created,purpose_of_request) VALUES('{$uReferenceID}','{$prfCompanySelected}','{$myDealerList}','{$prfCategorySelected}','{$CategorySubItem}','{$myUID}','{$prfApprovingHead}','{$getCompOfficer}','{$getGMApprover}','0','{$DateNeeded}','{$prfDate}','{$prfTime}','{$PurposeOfReqeust}')"); //ADD FIRST ITEM TO PRF DETAILS $hrdID = mysql_result(mysql_query("SELECT `id` FROM `prf_request_hdr` WHERE `reference_code`='$uReferenceID' AND comp_id ='$prfCompanySelected'"),0); mysql_query("INSERT INTO prf_request_detl(item_class,header_id,header_ref_code,comp_id,dealer_id,category_id,sub_category_id,item_description,uom,quantity,date_created, time_created) VALUES('{$itemCategoryID}','{$hrdID}','{$uReferenceID}','{$prfCompanySelected}','{$myDealerList}','{$prfCategorySelected}','{$CategorySubItem}','{$txtAddItemDesc}','{$UnitOfMeasure}','{$txtAddItemQty}','{$prfDate}','{$prfTime}')"); }else{ //ADD FIRST ITEM TO PRF DETAILS $hrdID = mysql_result(mysql_query("SELECT id from prf_request_hdr WHERE reference_code='$uReferenceID' AND comp_id ='$prfCompanySelected'"),0); mysql_query("INSERT INTO prf_request_detl(item_class,header_id,header_ref_code,comp_id,dealer_id,category_id,sub_category_id,item_description,uom,quantity,date_created, time_created) VALUES('{$itemCategoryID}','{$hrdID}','{$uReferenceID}','{$prfCompanySelected}','{$myDealerList}','{$prfCategorySelected}','{$CategorySubItem}','{$txtAddItemDesc}','{$UnitOfMeasure}','{$txtAddItemQty}','{$prfDate}','{$prfTime}')"); } $getItemDetl = mysql_query("SELECT * FROM prf_request_detl WHERE header_ref_code='$uReferenceID' AND `comp_id`='$prfCompanySelected'"); echo "<table>"; echo "<thead>"; echo "<th style='width:30px'>NO</th>"; echo "<th style='width:80px'>REF. #</th>"; echo "<th style='width:80px'>ITEM TYPE</th>"; echo "<th style='width:450px'>ITEM DESCRIPTION</th>"; echo "<th style='width:30px'>UoM</th>"; echo "<th style='width:40px'>QUANTITYx</th>"; echo "</thead>"; while($row=mysql_fetch_array($getItemDetl)){ $count = $count + 1; $itemClassID = $row['item_class']; $itemClassDes = mysql_result(mysql_query("SELECT `item_category` FROM `prf_item_category` WHERE `id`='$itemClassID'"),0); ?><tr><?php echo "<td>".strtoupper($row['id'])."</td>"; echo "<td>".strtoupper($itemClassDes)."</td>"; echo "<td>".strtoupper($row['header_ref_code'])."</td>"; echo "<td>".strtoupper($row['item_description'])."</td>"; echo "<td>".strtoupper($row['uom'])."</td>"; echo "<td style='text-align:center'>".strtoupper($row['quantity'])."</td>"; echo "</tr>"; } echo "</table>"; exit(); } ?> <!--- $##################################################################### --> <!--- $##################################################################### --> <div id="PRFDELETENewRequest" class="PopUpActionWindow" style='display:block'> <div class='PopUpWindowTitle'> 🪧 Confirm Action <div class='PopUpWindowClose'> <b onclick="javascript:hideDeleteAction(this);" style='font-weight:bold'> ✕ </b> </div> </div> <table> <tr> <td style='padding:10px;width:100%;background:white;font-family:Yu Gothic; font-size:16px;color:red ;height:10px;font-weight:normal;text-align:left'>Are you sure you want to delete the selected record? <input disabled type='hidden' id='DelActionReferenceID' style='text-align:center;margin-top:10px;background:yellow;border:0px;font-family:Yu Gothic;font-size:18px;color: red ;font-weight:bold;margin-bottom:3px;padding-bottom:2px'> <input disabled type='text' id='ActionReferenceIDDescXX' style='text-align:center;margin-top:10px;background:white;border:0px;font-family:Yu Gothic;font-size:18px;color: red ;font-weight:bold;margin-bottom:3px;padding-bottom:2px'> </td> </tr> <td colspan='2' style='padding:10px;width:250px;background:white;text-align:center'> <button onclick="javascript:hideDeleteAction(this);" class='PopUpLowerButtonR' style='width:45%'>📑 Cancel</button> <button id='deletePRFDetail' class='PopUpLowerButtonR' style='width:45%'> ❌ Delete</button> </td> </tr> </table> </div>
| ver. 1.4 |
.
| PHP 7.3.33 | Generation time: 0 |
proxy
|
phpinfo
|
Settings