//mail Settings include "be/inc/dbconn.php"; include "be/inc/function.php"; // A list of permitted file extensions $allowed = array('png', 'jpg', 'gif', 'zip'); $complaintNumber = $_POST["complaintNumber"]; if (isset($_FILES['upl']) && $_FILES['upl']['error'] == 0) { $extension = pathinfo($_FILES['upl']['name'], PATHINFO_EXTENSION); if (!in_array(strtolower($extension), $allowed)) { echo '{"status":"error"}'; exit; } $timestamp = time(); //timestamp $filename = $timestamp . "_" . $_FILES['upl']['name']; $folderPath = 'be/pics_upload/complaint/' . $complaintNumber; if (!file_exists($folderPath)) { mkdir($folderPath, 0777, true); } if (move_uploaded_file($_FILES['upl']['tmp_name'], $folderPath . "/" . $filename)) { $table = "complaint_pictures"; $fields = "picture_url,complaint_no"; $values = "'" . $filename . "'," . $complaintNumber; if (insertrec($table, $fields, $values)) { echo '{"status":"success"}'; } exit; } } //echo '{"status":"error"}'; //exit;
function convert2Failure() { $complaintNumber = $_GET["complaintNumber"]; $fields = "date_time,dealer_code,location_id,emp_code,cust_name,cust_address,cust_email,cust_mobile,model,veh_reg_no,frame_vin_no,engine_no,date_of_sale,km_reading,warranty,paid,photo_url,status"; $table1 = "complaint"; $table2 = "failure"; $rows = singlerec($fields, $table1, "complaint_no=" . $complaintNumber); $row = mysql_fetch_row($rows); $value = "'" . $row[0] . "'," . $row[1] . "," . $row[2] . ",'" . $row[3] . "','" . $row[4] . "','" . $row[5] . "','" . $row[6] . "'," . $row[7] . ",'" . $row[8] . "','" . $row[9] . "','" . $row[10] . "','" . $row[11] . "','" . $row[12] . "','" . $row[13] . "'," . $row[14] . "," . $row[15] . ",'" . $row[16] . "'," . $row[17]; if (insertrec($table2, $fields, $value)) { $failureID = mysql_insert_id(); //Move actions data //echo $failureID; $newField = "cat_id,customer_voice_id"; $rows = selectrec($newField, "complaint_details", "complaint_no=" . $complaintNumber); $newField1 = "cat_id,customer_voice_id,failure_id"; foreach ($rows as $row) { $value = $row[0] . "," . $row[1] . "," . $failureID; insertrec("failure_details", $newField1, $value); } deleterec("complaint_details", "complaint_no", $complaintNumber, "delete"); //move actions others data $newField = "cat_id,customer_voice_others"; $rows = selectrec($newField, "complaint_details_others", "complaint_no=" . $complaintNumber); $newField1 = "cat_id,customer_voice_others,failure_id"; foreach ($rows as $row) { $value = $row[0] . ",'" . $row[1] . "'," . $failureID; insertrec("failure_details_others", $newField1, $value); } deleterec("complaint_details_others", "complaint_no", $complaintNumber, "delete"); //move actions taken data $newField = "com_action,com_responsibility"; $rows = selectrec($newField, "complaint_actions_taken", "complaint_no=" . $complaintNumber); $newField1 = "action,failure_id"; foreach ($rows as $row) { $value = "'" . $row[0] . "-" . $row[1] . "'," . $failureID; insertrec("failure_actions_taken", $newField1, $value); } deleterec("complaint_actions_taken", "complaint_no", $complaintNumber, "delete"); //move Pictures $newField = "picture_url"; $rows = selectrec($newField, "complaint_pictures", "complaint_no=" . $complaintNumber); $newField1 = "picture_url,failure_id"; foreach ($rows as $row) { $value = "'" . $row[0] . "'," . $failureID; insertrec("failure_pictures", $newField1, $value); $fileURL = "http://gladminds.co/bajaj/fcr_mobile/be/"; $fromURL = "pics_upload/complaint/" . $complaintNumber . "/"; $toURL = "pics_upload/failure/" . $failureID . "/"; if (file_exists($fromURL . $row[0])) { $folderPath = "pics_upload/failure/" . $failureID; if (!file_exists($folderPath)) { mkdir($folderPath, 0777, true); } $file = $fromURL . $row[0]; $newfile = $toURL . $row[0]; if (!copy($file, $newfile)) { } else { //Remove the complaint file after copying //rmdir($fromURL.$row[0]); } } # if (!file_exists($toURL)) { # mkdir($toURL, 0777, true); # } # # echo "FailureID -->"."'".$toURL.$row[0]."'"; # # if(file_exists($fromURL.$row[0])){ # $file = $fromURL.$row[0]; # $newfile = $toURL.$row[0]; # copy($file, $newfile); # } } //Remove the Complaint Folder finally. if (file_exists($fromURL)) { rrmdir($fromURL); } deleterec("complaint_pictures", "complaint_no", $complaintNumber, "delete"); $arr = array('status' => 1, 'message' => 'Success'); deleterec($table1, "complaint_no", $complaintNumber, "delete"); } else { $arr = array('status' => 0, 'message' => 'Failure'); } echo json_encode($arr); }
function insertUpdate($table, $cols, $vals, $compField, $compCond) { if (singlefield($compField, $table, $compCond)) { // echo $compField.",".$compCond; $col_val = arrayToQuery($cols, $vals); if (updaterecs($table, $col_val, $compCond)) { $arr = array('status' => 1, 'message' => 'Sync Success', 'sync_time' => date("d/m/Y h:i:sa")); } else { $arr = array('status' => 0, 'message' => 'Sync Failure. Please try again'); } } else { $fields = rtrim(implode(',', $cols), ','); $vals = rtrim(implode(',', $vals), ','); if (insertrec($table, $fields, $vals)) { $arr = array('status' => 1, 'message' => 'Sync Success', 'sync_time' => date("d/m/Y h:i:sa")); } else { $arr = array('status' => 0, 'message' => 'Sync Failure. Please try again'); } } return $arr; }
function addAdmins($adminType) { $table = "users"; $username = $_POST['txtUsername']; $password = md5($_POST['txtPassword']); $name = $_POST['txtName']; $email = $_POST['txtEmail']; $mobile = $_POST['txtMobile']; $role = $_POST['txtRole'] ? $_POST['txtRole'] : 0; $admin = $adminType; // $username = "******"; // $password = md5("bajaj123"); // $name = "bAJAJ"; // $email = "*****@*****.**"; // $mobile = "9867727272"; // $admin = $adminType; $fields = "`username`,`password`,`name`,`email`,`mobile`,`admin`,`role`"; $value = "'" . $username . "','" . $password . "','" . $name . "','" . $email . "'," . $mobile . "," . $admin . "," . $role; if (insertrec($table, $fields, $value)) { $arr = array('status' => 1, 'message' => 'Success'); } else { $arr = array('status' => 0, 'message' => 'Insertion failure. Please retry with correct data'); } echo json_encode($arr); }