/manager/auth/order/quotation/generate.php
PHP | 297 lines | 163 code | 97 blank | 37 comment | 19 complexity | 1c08e0a394f27eca62d2f46d2c83f32f 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;
- $company=$_POST['company'];
- /*$array = explode('.', $companywfid);
- $fid=$array[0];
- $company=$array[1];*/
-
- $quotationnumber=$_POST['quotationnumber'];
- $_SESSION['quotationnumber']=$quotationnumber;
- $revisedno=$_POST['revisedno'];
- $currency=$_POST['currency'];
-
- $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'];
- /*for($m=0;$m<=3;$m++)
- {
- for($l=0;$l<=3;$l++)
- {
- echo $tax=$_POST['tax'];
- }
- }*/
- $tax=implode(",",$_POST['tax']);
-
-
-
- $_SESSION['fid']=null;
- $_SESSION['fid']=$fid;
-
- $_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
- $quotuniqueid = NewGuid();
- $_SESSION['quotuniqueid']=$quotuniqueid;
- $pathquot=null;
- $pathattachment=null;
- $allowed = array('png', 'jpg','jpeg', 'pdf', 'doc', 'docx', 'xls','xlsx','csv');
-
- /*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*/
-
- 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))
- {
-
- 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` (`Representive`,`RMail`,`UniqueId`,`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','$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,"insert into `quotation_all` (`Representive`,`RMail`,`UniqueId`,`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','$company','$product','$tax','$currency','$hsnsac','$servicename','$servicecost','$servicetax','$freightname','$freightcost','$freighttax','$partd','$qt','$unitp','$validity','$delivery','$payment','$newFilePathq','$newFilePatha','$remarks','$addreq','$licencefor','$expectedclosure','$quotformname')");*/
-
- }
- 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>alert("Data Inserted Successfully");location.replace("../../../opr/quotgen.php");</script>';
-
-
- echo '<script>location.replace("../../../opr/quotverify.php");</script>';
- /*echo '<script>location.replace("quotation.php");</script>';*/
-
-
- }
- else
- {
- echo '<script>alert("Data not Inserted ");location.replace("../../../opr/quotgen.php");</script>';
- }
- }
- echo '<script>location.replace("../../../opr/quotgen.php");</script>';
- ?>