コード例 #1
0
ファイル: PaymentTable.php プロジェクト: alsimfer/HomePage
 public function generateResponse()
 {
     $columns = array();
     $rows = array();
     $columns[] = array('sTitle' => 'Покупатель', 'aTargets' => array('0'), 'mData' => 'customer_name', 'sType' => 'string');
     $columns[] = array('sTitle' => 'Дата', 'aTargets' => array('1'), 'mData' => 'date', 'sType' => 'date', 'sClass' => 'right');
     $columns[] = array('sTitle' => 'Сумма', 'aTargets' => array('2'), 'mData' => 'paid_amount', 'sClass' => 'right', 'bSum' => TRUE);
     $columns[] = array('sTitle' => 'Банк', 'aTargets' => array('3'), 'mData' => 'bank_name', 'sType' => 'string');
     $columns[] = array('sTitle' => 'Доп. инфо', 'aTargets' => array('4'), 'mData' => 'extras', 'sType' => 'string');
     $query = 'SELECT payment.id,
                 (
                     CONCAT(customer.last_name, \' \', customer.first_name, \', \', email) 
                 ) AS customer_name, 
                 DATE_FORMAT(payment.date,\'%d.%m.%Y\') AS date,
                 payment.paid_amount, 
                 payment.bank_name, 
                 payment.extras 
             FROM deal
             JOIN payment ON payment.id = deal.payment_id
             JOIN customer ON customer.id = deal.customer_id
             WHERE deal.status = 1
             ORDER BY id';
     $rows = $this->db->select($query);
     $headerClasses = array();
     $headerClasses = util_UtilFunctions::getTHClasses($columns);
     $return['headerClasses'] = $headerClasses;
     $return['rows'] = $rows;
     $return['columns'] = $columns;
     return $return;
 }
コード例 #2
0
ファイル: CustomerTable.php プロジェクト: alsimfer/HomePage
 public function generateResponse()
 {
     $columns = array();
     $rows = array();
     $columns[] = array('sTitle' => 'ФИО', 'aTargets' => array('0'), 'mData' => 'full_name', 'sType' => 'string');
     $columns[] = array('sTitle' => 'Ник', 'aTargets' => array('1'), 'mData' => 'nick_name', 'sType' => 'string');
     $columns[] = array('sTitle' => 'email', 'aTargets' => array('2'), 'mData' => 'email', 'sType' => 'string');
     $columns[] = array('sTitle' => 'Адрес', 'aTargets' => array('3'), 'mData' => 'full_address', 'sType' => 'string');
     $columns[] = array('sTitle' => 'Телефон', 'aTargets' => array('4'), 'mData' => 'phone', 'sType' => 'number');
     $columns[] = array('sTitle' => 'Доп. инфо', 'aTargets' => array('5'), 'mData' => 'extras', 'sType' => 'string');
     $query = 'SELECT 
                 customer.id,
                 customer.last_name,
                 customer.first_name,
                 customer.middle_name,
             (
                 CONCAT (customer.last_name, \' \', customer.first_name, \' \', customer.middle_name)
             ) AS full_name,
                 customer.nick_name, 
                 customer.email, 
                 customer.extras,
             
                 contact.street,
                 contact.street_number,
                 contact.room_number,
                 contact.city,                    
                 contact.zip_code,
                 contact.country,
             (
                 CONCAT (
                     contact.street,
                     \' \', 
                     contact.street_number,
                     \', кв. \',
                     contact.room_number,
                             \', \',         
                     contact.city,
                     \', \',  
                     contact.zip_code,
                     \', \', 
                     contact.country)
             ) AS full_address,
                 contact.phone 
             FROM customer 
                 LEFT OUTER JOIN contact ON contact.customer_id = customer.id
             ORDER BY customer.id';
     $rows = $this->db->select($query);
     $headerClasses = array();
     $headerClasses = util_UtilFunctions::getTHClasses($columns);
     $return['headerClasses'] = $headerClasses;
     $return['rows'] = $rows;
     $return['columns'] = $columns;
     return $return;
 }
コード例 #3
0
ファイル: Payment.php プロジェクト: alsimfer/HomePage
 public function save($params, $payment_id = 0)
 {
     $returnArray = array();
     // Adjust the params for the further DB usage.
     foreach ($params as $key => $value) {
         $params[$key] = $this->db->res($value);
     }
     util_UtilFunctions::p($params);
     $validationArray = $this->validate($params);
     if (empty($validationArray) === FALSE) {
         $returnArray['result'] = FALSE;
         $returnArray['error'] = implode(' ', $validationArray);
     } else {
         // Check if we are adding a new Payment or updating an old one.
         if ((int) $payment_id > 0) {
             $query = '
                     UPDATE payment
                     SET 
                         date = ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',
                         paid_amount = ' . (double) $params['paid_amount'] . ',
                         bank_name = ' . $this->db->quote($params['bank_name']) . ',
                         extras = ' . $this->db->quote($params['extras']) . '
                     WHERE id = ' . (int) $payment_id . '
                             ';
         } else {
             $query = '
                 INSERT INTO payment (id, date, paid_amount, bank_name, extras)
                     VALUES (
                         DEFAULT,
                         ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',
                         ' . (double) $params['paid_amount'] . ',
                         ' . $this->db->quote($params['bank_name']) . ',
                         ' . $this->db->quote($params['extras']) . '
                     )';
         }
         $result = $this->db->query($query);
         $returnArray = array();
         $returnArray['result'] = $result;
         $returnArray['error'] = $this->db->error();
     }
     return $returnArray;
 }
コード例 #4
0
ファイル: Shipment.php プロジェクト: alsimfer/HomePage
 public function save($params, $shipment_id = 0)
 {
     $returnArray = array();
     // Adjust the params for the further DB usage.
     foreach ($params as $key => $value) {
         $params[$key] = $this->db->res($value);
     }
     $validationArray = $this->validate($params);
     if (empty($validationArray) === FALSE) {
         $returnArray['result'] = FALSE;
         $returnArray['error'] = implode(' ', $validationArray);
     } else {
         // Check if we are adding a new Customer or updating an old one.
         if ((int) $shipment_id > 0) {
             $query = '
             UPDATE shipment SET 
                     number = ' . $this->db->quote($params['number']) . ',
                     date = ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',  
                     transport_charge = ' . (double) $params['transport_charge'] . ',
                     extras = ' . $this->db->quote($params['extras']) . ' 
                 WHERE id = ' . (int) $shipment_id . '';
         } else {
             $query = '
             INSERT INTO shipment (id, number, date, transport_charge, extras)
                 VALUES (
                     DEFAULT,                        
                     ' . $this->db->quote($params['number']) . ',
                     ' . $this->db->quote(util_UtilFunctions::dateFormat($params['date'], 'sql')) . ',
                     ' . (double) $params['transport_charge'] . ',
                     ' . $this->db->quote($params['extras']) . '
                             
                 )';
         }
         $result = $this->db->query($query);
         $returnArray = array();
         $returnArray['result'] = $result;
         $returnArray['error'] = $this->db->error();
     }
     return $returnArray;
 }
コード例 #5
0
ファイル: SelectField.php プロジェクト: alsimfer/HomePage
 /**	 
  * @return string
  */
 public function generateHTML($options = array())
 {
     $string = '<select id=\'' . $this->id . '\' name=\'' . $this->name . '\' class=\'' . $this->css_class . '\'>';
     if (empty($options) === FALSE) {
         foreach ($options as $index => $row) {
             if ((int) $this->selected_id === (int) $row['id']) {
                 $string .= '<option selected=\'selected\' value=\'' . $row['id'] . '\'>' . $row['sf_option'] . '</option>';
             } else {
                 $string .= '<option value=\'' . $row['id'] . '\'>' . $row['sf_option'] . '</option>';
             }
         }
     }
     $string .= '</select>';
     $script = '$(function() {
                 $(\'#' . $this->id . '\').select2({
                     placeholder: \'' . $this->placeHolder . '\'
                     
                 }); 
             });';
     $string .= '<script>' . $script . '</script>';
     util_UtilFunctions::p($string);
     return $string;
 }
コード例 #6
0
ファイル: Deal.php プロジェクト: alsimfer/HomePage
 public function save($params, $deal_id = 0)
 {
     $returnArray = array();
     // Adjust the params for the further DB usage.
     foreach ($params as $key => $value) {
         $params[$key] = $this->db->res($value);
     }
     util_UtilFunctions::p($params);
     $validationArray = $this->validate($params);
     if (empty($validationArray) === FALSE) {
         $returnArray['result'] = FALSE;
         $returnArray['error'] = implode(' ', $validationArray);
     } else {
         // Check if we are adding a new Customer or updating an old one.
         if ((int) $deal_id > 0) {
             $query = '
             UPDATE deal SET
                     customer_id = ' . (int) $params['customer_id'] . ', 
                     article_id = ' . (int) $params['article_id'] . ', 
                     amount = ' . (int) $params['amount'] . ', 
                     total_price = ' . (double) $params['total_price'] . ', 
                     platform_name = ' . $this->db->quote($params['platform_name']) . ', 
                     commented = ' . (int) $params['commented'] . ', 
                     status = ' . (int) $params['status'] . ', 
                     extras = ' . $this->db->quote($params['extras']) . '
                 WHERE id = ' . (int) $deal_id . '
                 ';
         } else {
             // Save deal with shipment and payment.
             $query = '
             INSERT INTO shipment (id, number, date, transport_charge, extras)
                 VALUES (
                     DEFAULT,
                     0,
                     \'0000-00-00\',
                     0,
                     \'\'                                
                 )';
             $result = $this->db->query($query);
             if ($result === FALSE) {
                 $returnArray = array();
                 $returnArray['result'] = $result;
                 $returnArray['error'] = $this->db->error();
                 return $returnArray;
             }
             $last_shipment_id = $this->db->getLastId();
             $query = '
             INSERT INTO payment (id, date, paid_amount, bank_name, extras)
                 VALUES (
                     DEFAULT,
                     \'0000-00-00\',
                     0,
                     \'\',
                     \'\'
                 )';
             $result = $this->db->query($query);
             if ($result === FALSE) {
                 $returnArray = array();
                 $returnArray['result'] = $result;
                 $returnArray['error'] = $this->db->error();
                 return $returnArray;
             }
             $last_payment_id = $this->db->getLastId();
             $query = '
             INSERT INTO deal (id, customer_id, article_id, payment_id, shipment_id, amount, total_price, platform_name, commented, status, extras)
                 VALUES (
                     DEFAULT,
                     ' . (int) $params['customer_id'] . ',
                     ' . (int) $params['article_id'] . ',
                     ' . (int) $last_payment_id . ',
                     ' . (int) $last_shipment_id . ',
                     ' . (int) $params['amount'] . ',
                     ' . (double) $params['total_price'] . ',
                     ' . $this->db->quote($params['platform_name']) . ',
                     ' . (int) $params['commented'] . ',                                
                     ' . (int) $params['status'] . ',                                
                     ' . $this->db->quote($params['extras']) . '                                
                 )';
         }
         $result = $this->db->query($query);
         $returnArray = array();
         $returnArray['result'] = $result;
         $returnArray['error'] = $this->db->error();
     }
     return $returnArray;
 }
コード例 #7
0
ファイル: Uploader.php プロジェクト: alsimfer/HomePage
 public function getResult()
 {
     $return = array('messages' => array('info' => '', 'success' => '', 'danger' => ''));
     $target_dir = "images/article/";
     $image_name = strtolower(basename($this->params["input_image"]["name"]));
     util_UtilFunctions::p($image_name);
     $image_name = strtolower(end(explode('/', $this->params["input_image"]["name"])));
     util_UtilFunctions::p($image_name);
     $target_file = $target_dir . $image_name;
     $uploadOk = 1;
     $imageFileType = strtolower(pathinfo($target_file, PATHINFO_EXTENSION));
     // Check if image file is a actual image or fake image
     if (isset($_POST["submit"])) {
         $check = getimagesize($this->params["input_image"]["tmp_name"]);
         if ($check !== false) {
             $return['messages']['info'] = "File is an image - " . $check["mime"] . ".";
             $uploadOk = 1;
         } else {
             $return['messages']['danger'] = "File is not an image. ";
             $uploadOk = 0;
         }
     }
     // Check if file already exists
     if (file_exists($target_file)) {
         $return['messages']['danger'] .= "Sorry, file already exists. ";
         $uploadOk = 0;
     }
     // Check file size
     if ($this->params["input_image"]["size"] > 5000000) {
         $return['messages']['danger'] .= "Sorry, your file is too large. ";
         $uploadOk = 0;
     }
     // Allow certain file formats
     if ($imageFileType != "jpg" && $imageFileType != "png" && $imageFileType != "jpeg" && $imageFileType != "gif") {
         $return['messages']['danger'] .= "Sorry, only JPG, JPEG, PNG & GIF files are allowed. ";
         $uploadOk = 0;
     }
     // Check if $uploadOk is set to 0 by an error
     if ($uploadOk == 0) {
         $return['messages']['danger'] .= "Sorry, your file was not uploaded. ";
         // if everything is ok, try to upload file
     } else {
         if (move_uploaded_file($this->params["input_image"]["tmp_name"], $target_file)) {
             $return['messages']['success'] = "The file " . basename($this->params["input_image"]["name"]) . " has been uploaded. ";
             $uploadOk = 1;
         } else {
             $return['messages']['danger'] .= "Sorry, there was an error uploading your file.";
         }
     }
     // Add a reference to the DB.
     $query = 'UPDATE article 
                 SET 
                     image_path = \'article/' . $image_name . '\'
                 WHERE id = ' . $this->params['article_id'] . '
                         ';
     $result = $this->db->query($query);
     if ($result === TRUE) {
         $return['messages']['success'] .= "The reference was successfully added to the article.";
     } else {
         $return['messages']['danger'] .= "Couldn't assign a reference to the image in the DB.";
     }
     return json_encode($return);
 }