/user/auth/customer/icmp.php
PHP | 204 lines | 128 code | 57 blank | 19 comment | 11 complexity | ddc060a95154160f49754bb5899a3eee 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";
- ?>
- <?php
- if(isset($_POST['submit']))
- {
- $rep=$_SESSION['n'];
- $rmail=$id;
-
-
- $company=$_POST['company'];
- $sector=$_POST['sector'];
- $subsector=$_POST['subsector'];
-
-
- $url=$_POST['url'];
- $address=$_POST['address'];
- $location=$_POST['location'];
- $sublocation=$_POST['sublocation'];
- $city=$_POST['city'];
- $pin=$_POST['pin'];
- $state=$_POST['state'];
- $country=$_POST['country'];
- $stdcode=$_POST['stdcode'];
- $landlineno=$_POST['landlineno'];
- $faxno=$_POST['faxno'];
- $noofemployees=$_POST['noofemployees'];
- $companytype=$_POST['companytype'];
- $companytype=$_POST['companytype'];
- $gstno=$_POST['gstno'];
- $datafrom=$_POST['datafrom'];
- // 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
- $custuniqueid = NewGuid();
-
- /*check columns available start*/
-
- $result=mysqli_query($dbc,"show columns from customers");
- $k=0;
- $c=0;
- while($row = mysqli_fetch_array($result)){
- $str=$row['Field'];
-
- $newstr = filter_var($str, FILTER_SANITIZE_STRING);
- if($newstr="ContactName")
- {
- $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 < 50; $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
- $name=$_POST['name'][$i];
- $designation=$_POST['designation'][$i];
- $level=$_POST['level'][$i];
- $department=$_POST['department'][$i];
- $email=$_POST['email'][$i];
- $mobile=$_POST['mobile'][$i];
-
- if(!empty($name))
- {
-
- if($i=='0')
- {
- $ad=mysqli_query($dbc,"insert into `customers` (`Representive`,`RMail`,`UniqueId`,`Company`,`Sector`,`SubSector`,`ContactName1`,`ContactDesignation1`,`ContactLevel1`,`ContactDept1`,`ContactMobile1`,`ContactMail1`,`Url`,`Address`,`Location`,`SubLocation`,`City`,`Pin`,`State`,`StdCode`,`LandlineNo`,`FaxNo`,`NoOfEmployees`,`CompanyType`,`GSTNo`) values ('$rep','$rmail','$custuniqueid','$company','$sector','$subsector','$name','$designation','$level','$department','$mobile','$email','$url','$address','$location','$sublocation','$city','$pin','$state','$stdcode','$landlineno','$faxno','$noofemployees','$companytype','$gstno')");
-
- }
- elseif($i>=1)
- {
- if($i==$c)
- {
- $namenew="ContactName".($c+1);
- $designationnew="ContactDesignation".($c+1);
- $levelnew="ContactLevel".($c+1);
- $departmentnew="ContactDept".($c+1);
-
- $emailnew="ContactMail".($c+1);
- $mobilenew="ContactMobile".($c+1);
-
- mysqli_query($dbc,"ALTER TABLE `customers` ADD `$namenew` TEXT NULL, ADD `$designationnew` TEXT NULL,ADD `$levelnew` TEXT NULL,ADD `$departmentnew` TEXT NULL,ADD `$emailnew` TEXT NULL,ADD `$mobilenew` TEXT NULL");
-
-
- $c=$c+1;
- }
-
- $ii=$i+1;
- $namecolumn="ContactName".$ii;
- $designationcolumn="ContactDesignation".$ii;
- $levelcolumn="ContactLevel".$ii;
- $departmentcolumn="ContactDept".$ii;
- $emailcolumn="ContactMail".$ii;
- $mobilecolumn="ContactMobile".$ii;
-
- $ad=mysqli_query($dbc,"update `customers` set `$namecolumn`='$name',`$designationcolumn`='$designation',`$levelcolumn`='$level',`$departmentcolumn`='$department',`$emailcolumn`='$email',`$mobilecolumn`='$mobile' where `RMail`='$rmail' and `UniqueId`='$custuniqueid' ");
-
-
-
- }
- else
- {
- echo '<script>alert("Sorry!! Maximum Description Reached");location.replace("../../opr/addcust.php");</script>';
- }
- }
- else
- {
- break;
- }
-
-
- }
- if($ad>0)
- {
- if($datafrom == 'quotgen')
- {
- echo '<script>alert("Data Inserted Successfully");window.history.back();</script>';
- }
- else
- {
- echo '<script>alert("Data Inserted Successfully");location.replace("../../opr/addcust.php");</script>';
- }
- }
- else
- {
- echo '<script>alert("Data not Inserted");location.replace("../../opr/addcust.php");</script>';
- }
-
-
-
- /* while($r=mysqli_fetch_row($ad))
- {
-
- if($r>0)
- {
- $_SESSION['id']=$id;
- echo '<script>location.replace("dashboard.php");</script>';
- }
-
-
-
- }
- */
- }
- echo '<script>location.replace("../../opr/addcust.php");</script>';
- ?>