コード例 #1
0
ファイル: users.php プロジェクト: wangshipeng/license_manager
 public function uploadUserPhoto($file, $params = array())
 {
     if (!empty($file) && strlen($params["guid"]) > 0) {
         $db = new clsDBdbConnection();
         $options = Options::getConsoleOptions();
         $uploadTo = $options["console_users_url"];
         $tmpFile = $file["file"]["tmp_name"];
         $fileName = $file["file"]["name"];
         $targetPath = dirname(__FILE__) . "/.." . $uploadTo;
         //because dirname will be positioned in include folder
         $fileExt = "." . pathinfo($fileName, PATHINFO_EXTENSION);
         $targetFilename = Options::getUUIDv6() . $fileExt;
         $targetFile = $targetPath . $targetFilename;
         //Updating an existing image, which will replace the existing one for the new
         $params["guid"] = $db->esc($params["guid"]);
         $existing_photo = CCDLookUp("photo", "alm_users", "guid = '{$params["guid"]}'", $db);
         $existing_photo = trim($existing_photo);
         if (strlen($existing_photo) > 0) {
             //Get the existing image name to re-use it and replace image on upload
             $targetFilename = $existing_photo;
             $targetFile = $targetPath . $targetFilename;
         }
         if (move_uploaded_file($tmpFile, $targetFile)) {
             //File successfully uploaded
             $params["image_name"] = $targetFilename;
             //Saving db file reference
             $this->saveCustomerImage($params);
             $db->close();
             return true;
         } else {
             $db->close();
             return false;
         }
         /*
         $log  = new Logger('almlogs');
         $log->pushHandler(new StreamHandler(MAIN_LOG, Logger::WARNING));
         $log->addWarning($params["guid"].LOG_LINESEPARATOR);
         $log->addWarning($params["title"].LOG_LINESEPARATOR);
         */
     } else {
         return false;
     }
 }
コード例 #2
0
 private function setCheckinEmailOrder($orderid, $userid, $venue_id)
 {
     if ($orderid > 0 && $userid > 0 && $venue_id > 0) {
         $db = new clsDBdbConnection();
         $guid = Options::getUUIDv6();
         $sql = "insert into ppconsole_ticketscheckin(guid,order_id,checkin_userid,checkin_venueid,created_iduser)\n                    values('{$guid}',{$orderid},{$userid},{$venue_id},{$userid}) ";
         $db->query($sql);
         $db->close();
         return true;
     } else {
         return false;
     }
 }
コード例 #3
0
 public function setEmailNotification($orderid, $userid)
 {
     if ($orderid > 0) {
         $db = new clsDBdbConnection();
         $guid = Options::getUUIDv6();
         $orderid = (int) $orderid;
         $customer_id = (int) CCDLookUp("customer_id", "orders", "id = {$orderid}", $db);
         $email = CCDLookUp("email", "customers", "id = {$customer_id}", $db);
         $sql = "insert into email_notifications (guid,customer_id,email,order_id,created_iduser)\n                    values ('{$guid}',{$customer_id},'{$email}',{$orderid},{$userid})";
         $db->query($sql);
         $db->next_record();
         $db->close();
         return true;
     } else {
         return false;
     }
 }
コード例 #4
0
 public function setPaymentTerminal($payment_type, $currency_id, $approval_number, $payment_amount, $orderid, $userid)
 {
     $orderid = (int) $orderid;
     $result = array("status" => false, "message" => "");
     if ($orderid > 0) {
         $db = new clsDBdbConnection();
         $currency_id = (int) $currency_id;
         $order_total = (double) CCDLookUp("total", "orders", "id = {$orderid}", $db);
         $payment_amount = (double) $payment_amount;
         $payment_type = (int) $payment_type;
         $approval_number = $db->esc($approval_number);
         if ($payment_amount >= $order_total) {
             if (strlen($approval_number) > 0 && $payment_type > 0) {
                 $guid = Options::getUUIDv6();
                 $amount_residual = $payment_amount - $order_total;
                 $total_paid = $payment_amount - $amount_residual;
                 $sql = "insert into ppconsole_payments(guid,currency_id,order_id,total_paid,amount_received,amount_residual,created_userid,approval_number,paymenttype_id)\n                            values('{$guid}',{$currency_id},{$orderid},{$total_paid},{$payment_amount},{$amount_residual},{$userid},'{$approval_number}',{$payment_type}) ";
                 $db->query($sql);
                 $db->next_record();
                 //Update order status after payment confirmation
                 $sql = "update orders set status_id = 3,modified_iduser = {$userid} where id = {$orderid}";
                 $db->query($sql);
                 $db->next_record();
                 $result["status"] = true;
                 $result["message"] = "Order has been paid successfully";
                 //Notify the customer and notification list that payment for the order has been approved
                 $this->setNotificationOrderPaid($orderid, $userid);
             } else {
                 $result["status"] = false;
                 $result["message"] = "Invalid approval number or payment type";
             }
         } else {
             $result["status"] = false;
             $result["message"] = "Input amount is less than order total";
         }
         $db->close();
         return $result;
     } else {
         $result["status"] = false;
         $result["message"] = "Invalid order id";
         return $result;
     }
 }