/manager/auth/order/quotation/updquot.php
PHP | 354 lines | 169 code | 112 blank | 73 comment | 20 complexity | f8a39244b98bbd2a1c21e829c45e516a MD5 | raw file
Possible License(s): Unlicense, GPL-2.0, GPL-3.0
- <?php
- session_start();
- error_reporting(E_PARSE | E_ERROR);
- $id=$_SESSION['id'];
- if(!$_SESSION['id'])
- {
- echo '<script>location.replace("../../../../../index.php");</script>';
- }
- require_once "../../../conn/conn.php";
- $chk=mysqli_query($dbc,"select * from team where email='$id'");
- while($fchk=mysqli_fetch_assoc($chk))
- {
- $type=$fchk['EmployeeType'];
- if( $type !="Manager")
- {
- echo '<script>location.replace("../../../../index.php");</script>';
- }
- }
- ?>
- <?php
- if(isset($_POST['submit']))
- {
- $rep=$_SESSION['n'];
- $rmail=$id;
- $quotno=$_POST['quotno'];
-
- $company=$_POST['company'];
- /*$array = explode('.', $companywfid);
- $fid=$array[0];
- $company=$array[1];*/
-
- /*$quotationnumber=$_POST['quotationnumber'];
- $_SESSION['quotationnumber']=$quotationnumber;*/
- $qtype=$_POST['qtype'];
-
- //$_SESSION['qtype']=$qtype;
- $quotuniqueid=$_POST['uniqueid'];
-
- $_SESSION['qu']=$quotuniqueid;
-
-
- /*$quotuniqueid=$_POST['uniqueid'];
- $_SESSION['quotuniqueid']=$quotuniqueid;*/
- $currency=$_POST['currency'];
- $hsnsac=$_POST['hsnsac'];
- $validity=$_POST['validity'];
- $delivery=$_POST['delivery'];
- $service=$_POST['service'];
- $payment=$_POST['payment'];
- $servicename=$_POST['servicename'];
- $servicecost=$_POST['servicecost'];
- $servicetax=$_POST['servicetax'];
- $freightname=$_POST['freightname'];
- $freightcost=$_POST['freightcost'];
- $freighttax=$_POST['freighttax'];
- $expectedclosure=$_POST['expectedclosure'];
- $addreq=$_POST['addreq'];
- $quotformname=$_POST['quotformname'];
- $remarks=$_POST['remarks'];
- $tax=implode(',', $_POST['tax']);
-
- $_SESSION['fid']=null;
-
- $_SESSION['qcompany']=$company;
- /*$_SESSION['qproduct']=$product;*/
- // Generate Guid - unique id
- function NewGuid() {
- $s = strtoupper(md5(uniqid(rand(),true)));
-
- date_default_timezone_set('Asia/Kolkata');
- $timestamp = date('dmYHis', time());
- $guidText =
- substr($timestamp,0,18) . '-' .
- substr($s,18,4) . '-' .
- substr($s,22,4). '-' .
- substr($s,26,4). '-' .
- substr($s,30);
- return $guidText;
- }
- // End Generate Guid
- if($qtype>1)
- {
- $quotuniqueid = NewGuid();
- }
- $_SESSION['quotuniqueid']=$quotuniqueid;
- $pathquot=null;
- $pathattachment=null;
- $allowed = array('png', 'jpg','jpeg', 'pdf', 'doc', 'docx', 'xls','xlsx','csv');
- /*upload quotation*/
- /*if(isset($_FILES['uplfiles']) && $_FILES['uplfiles']['error'] == 0){
- $extension = pathinfo($_FILES['uplfiles']['name'], PATHINFO_EXTENSION);
- if(!in_array(strtolower($extension), $allowed)){
-
-
-
- }
- if(move_uploaded_file($_FILES['uplfiles']['tmp_name'], '../../../../../uploadfiles/quotation/'.$company.'.'.$fid.'.'.$_FILES['uplfiles']['name'])){
- global $path;
- $pathquot=$company.'.'.$fid.'.'.$_FILES['uplfiles']['name'];
- }
- }
- */
- // Count # of uploaded files in array
- /*$total = count($_FILES['uplfiles']['name']);*/
- // Loop through each file
- /*for( $i=0 ; $i < $total ; $i++ ) {*/
- //Get the temp file path
- /*$tmpFilePath = $_FILES['uplfiles']['tmp_name'][$i];*/
- //Make sure we have a file path
- /*if ($tmpFilePath != ""){*/
- //Setup our new file path
- /*$newFilePath = "../../../../../uploadfiles/quotation/" . $_FILES['uplfiles']['name'][$i];*/
- //Upload the file into the temp dir
- /*if(move_uploaded_file($tmpFilePath, $newFilePath)) {*/
- //Handle other code here
- /* }
- }
- }*/
- /*check columns available start*/
-
- $result=mysqli_query($dbc,"show columns from quotation");
- $k=0;
- $c=0;
- while($row = mysqli_fetch_array($result)){
- $str=$row['Field'];
-
- $newstr = filter_var($str, FILTER_SANITIZE_STRING);
- if($newstr="Product")
- {
- $int_id = filter_var($str, FILTER_SANITIZE_NUMBER_INT);
-
- if($int_id > $k)
- {
- global $c;
- $c=$int_id;
- $k=$int_id;
-
- }
- }
-
- }
- /*check columns available end*/
-
- //echo $_POST['qty'];
-
- for ($i = 0; $i < 500; $i++)
- {
- /*if (isset($_POST['partdesc'][$i], $_POST['qty'][$i],$_POST['unitprice'][$i])) { // Make sure both are filled in*/
- // Do stuff with this row of the form
- $product=$_POST['product'][$i];
- $partd=$_POST['partdesc'][$i];
- $qt=$_POST['qty'][$i];
- $unitp=$_POST['unitprice'][$i];
- $licencefor=$_POST['licencefor'][$i];
- $hsnsac=$_POST['hsnsac'][$i];
-
- if(!empty($product) and !empty($unitp))
- {
-
- if($i=='0')
- {
- //Get the temp file path
- $tmpFilePath = $_FILES['uplfiles']['tmp_name'][$i];
- //Make sure we have a file path
- if ($tmpFilePath != ""){
- //Setup our new file path
- $newFilePath = "../../../../uploadfiles/quotation/".$quotuniqueid."-".$_FILES['uplfiles']['name'][$i];
- //Upload the file into the temp dir
- if(move_uploaded_file($tmpFilePath, $newFilePath)) {
- //Handle other code here
- $newFilePathq = $quotuniqueid."-".$_FILES['uplfiles']['name'][$i];
- }
- }
- //Get the temp attachment path
- $tmpFilePath = $_FILES['attachment']['tmp_name'][$i];
- //Make sure we have a file path
- if ($tmpFilePath != ""){
- //Setup our new file path
- $newFilePath1 = "../../../../uploadfiles/quotation/".$quotuniqueid."-".$_FILES['attachment']['name'][$i];
- //Upload the file into the temp dir
- if(move_uploaded_file($tmpFilePath, $newFilePath1)) {
- //Handle other code here
- $newFilePatha = $quotuniqueid."-".$_FILES['attachment']['name'][$i];
- }
- }
-
- $ad=mysqli_query($dbc,"insert into `quotation_all` (`Representive`,`RMail`,`UniqueId`,`QuotNo`,`Company`,`Product1`,`Tax`,`Currency`,`HSNSAC1`,`ServiceName`,`ServiceCost`,`ServiceTax`,`FreightName`,`FreightCost`,`FreightTax`,`PartDescription1`,`Quantity1`,`UnitPrice1`,`Validity`,`Delivery`,`Payment`,`QuotationPath1`,`Attachment1`,`Remarks`,`AddressReq`,`LicenceFor1`,`ExpectedClosure`,`QuotFormName`) values ('$rep','$rmail','$quotuniqueid','$quotno','$company','$product','$tax','$currency','$hsnsac','$servicename','$servicecost','$servicetax','$freightname','$freightcost','$freighttax','$partd','$qt','$unitp','$validity','$delivery','$payment','$newFilePathq','$newFilePatha','$remarks','$addreq','$licencefor','$expectedclosure','$quotformname')");
- $ad=mysqli_query($dbc,"update `quotation` set `UniqueId`='$quotuniqueid',`Company`='$company',`Product1`='$product',`Tax`='$tax',`Currency`='$currency',`HSNSAC1`='$hsnsac',`ServiceName`='$servicename',`ServiceCost`='$servicecost',`ServiceTax`='$servicetax',`FreightName`='$freightname',`FreightCost`='$freightcost',`FreightTax`='$freighttax',`PartDescription1`='$partd',`Quantity1`='$qt',`UnitPrice1`='$unitp',`Validity`='$validity',`Delivery`='$delivery',`Payment`='$payment',`QuotationPath1`='$newFilePathq',`Attachment1`='$newFilePatha',`Remarks`='$remarks',`AddressReq`='$addreq',`LicenceFor1`='$licencefor',`ExpectedClosure`='$expectedclosure',`QuotFormName`='$quotformname' where `QuotNo`='$quotno' ");
-
- }
- elseif($i>=1)
- {
- if($i==$c)
- {
- $productnew="Product".($c+1);
- $partdescnew="PartDescription".($c+1);
- $quantitynew="Quantity".($c+1);
- $unitpricenew="UnitPrice".($c+1);
-
- $hsnsacnew="HSNSAC".($c+1);
- $quotationpathnew="QuotationPath".($c+1);
- $attachmentnew="Attachment".($c+1);
- $licencefornew="LicenceFor".($c+1);
- mysqli_query($dbc,"ALTER TABLE `quotation` ADD `$productnew` TEXT NULL, ADD `$partdescnew` TEXT NULL,ADD `$quantitynew` TEXT NULL,ADD `$unitpricenew` TEXT NULL,ADD `$hsnsacnew` TEXT NULL,ADD `$quotationpathnew` TEXT NULL,ADD `$attachmentnew` TEXT NULL,ADD `$licencefornew` TEXT NULL");
- mysqli_query($dbc,"ALTER TABLE `quotation_all` ADD `$productnew` TEXT NULL, ADD `$partdescnew` TEXT NULL,ADD `$quantitynew` TEXT NULL,ADD `$unitpricenew` TEXT NULL,ADD `$hsnsacnew` TEXT NULL,ADD `$quotationpathnew` TEXT NULL,ADD `$attachmentnew` TEXT NULL,ADD `$licencefornew` TEXT NULL");
- $c=$c+1;
- }
-
- //Get the temp file path
- $tmpFilePath = $_FILES['uplfiles']['tmp_name'][$i];
- //Make sure we have a file path
- if ($tmpFilePath != ""){
- //Setup our new file path
- $newFilePath = "../../../../uploadfiles/quotation/".$quotuniqueid."-".$_FILES['uplfiles']['name'][$i];
- //Upload the file into the temp dir
- if(move_uploaded_file($tmpFilePath, $newFilePath)) {
- //Handle other code here
- $newFilePathtwo = $quotuniqueid."-".$_FILES['uplfiles']['name'][$i];
- }
- }
- $ii=$i+1;
- $productcolumn="Product".$ii;
- $partdescolumn="PartDescription".$ii;
- $quantitycolumn="Quantity".$ii;
- $unitpricecolumn="UnitPrice".$ii;
- $quotationpathcolumn="QuotationPath".$ii;
- $hsnsaccolumn="HSNSAC".$ii;
- $licenceforcolumn="LicenceFor".$ii;
- $ad=mysqli_query($dbc,"update `quotation` set `$productcolumn`='$product',`$partdescolumn`='$partd',`$quantitycolumn`='$qt',`$unitpricecolumn`='$unitp',`$quotationpathcolumn`='$newFilePathtwo',`$hsnsaccolumn`='$hsnsac',`$licenceforcolumn`='$licencefor' where `RMail`='$rmail' and `UniqueId`='$quotuniqueid' ");
- $ad=mysqli_query($dbc,"update `quotation_all` set `$productcolumn`='$product',`$partdescolumn`='$partd',`$quantitycolumn`='$qt',`$unitpricecolumn`='$unitp',`$quotationpathcolumn`='$newFilePathtwo',`$hsnsaccolumn`='$hsnsac',`$licenceforcolumn`='$licencefor' where `RMail`='$rmail' and `UniqueId`='$quotuniqueid' ");
-
-
- }
- else
- {
- echo '<script>alert("Sorry!! Maximum Description Reached");location.replace("../../../opr/quotgen.php");</script>';
- }
- }
- else
- {
- break;
- }
-
-
- }
-
- if($ad>0)
- {
-
-
-
- echo '<script>location.replace("../../../opr/quotverify.php");</script>';
-
-
-
- }
- else
- {
- echo '<script>alert("Data not Updated ");location.replace("../../../opr/quotdash.php");</script>';
- }
- }
- echo '<script>location.replace("../../../opr/quotdash.php");</script>';
- ?>