Example #1
0
 function deleteInventry()
 {
     $result = $this->db_handler->delete_model($this);
     $description = "Inventry deleted, result : " . $result;
     Log::i($this->tag, $description);
     return $result;
 }
 function updateBankDeposit()
 {
     $result = $this->db_handler->update_model($this);
     $description = "Updating BankDeposit (" . $this->to_string() . ")";
     Log::i($this->tag, $description);
     return $result;
 }
Example #3
0
 function deleteExpence()
 {
     $result = $this->db_handler->delete_model($this);
     $description = "Expence deleted, result : " . $result;
     Log::i($this->tag, $description);
     return $result;
 }
Example #4
0
 function deleteWendor()
 {
     $result = $this->db_handler->delete_model($this);
     $description = "Vendor deleted, result : " . $result;
     Log::i($this->tag, $description);
     return $result;
 }
Example #5
0
 function deleteCompany()
 {
     $result = $this->db_handler->delete_model($this);
     if ($result) {
         $description = "Company deleted, id : " . $this->id;
         Log::i($this->tag, $description);
     }
     return $result;
 }
 function addPurchaceItem($purchace_item = null)
 {
     if ($purchace_item == null) {
         $purchace_item = $this;
     }
     $this->db_handler->add_model($purchace_item);
     $description = "Added new Purchace item (" . $purchace_item->to_string() . ")";
     Log::i($this->tag, $description);
 }
 function deleteTaxCategory()
 {
     $result = $this->db_handler->delete_model($this);
     if ($result) {
         $description = "Tax Category deleted, Tax Category ID : " . $this->id;
         Log::i($this->tag, $description);
     }
     return $result;
 }
Example #8
0
 function updateBank($bank = null)
 {
     if ($bank == null) {
         $bank = $this;
     }
     if ($this->db_handler->update_model($bank)) {
         $description = "Updated bank (" . $bank->to_string() . ")";
         Log::i($this->tag, $description);
         return True;
     } else {
         return FALSE;
     }
 }
 function addSaleItem($sale_item = null)
 {
     if ($sale_item == null) {
         $sale_item = $this;
     }
     $result = $this->db_handler->add_model($sale_item);
     if ($result) {
         $description = "Added new Sale Item (" . $sale_item->to_string() . ")";
         Log::i($this->tag, $description);
     } else {
         $description = "Adding new Sale Item failed (" . $sale_item->to_string() . ")";
         $description = $description . mysql_error();
         Log::i($this->tag, $description);
     }
 }
Example #10
0
 /**
  * 某个企业的临时授权码在成功换取永久授权码后,开放平台将不再推送该企业临时授权码。
  */
 public static function autoActivateSuite($tmpAuthCode)
 {
     $suiteAccessToken = Service::getSuiteAccessToken($suiteTicket);
     Log::i("[Activate] getSuiteToken: " . $suiteAccessToken);
     /**
      * 企业永久授权码信息须持久化保持,在demo中只做缓存处理。
      */
     $permanetCodeInfo = json_decode(Cache::getPermanentAuthCodeInfo());
     if (!$permanetCodeInfo) {
         $suiteTicket = Cache::getSuiteTicket();
         Log::i("[Activate] getSuiteTicket: " . $suiteTicket);
         /**
          * 获取企业永久授权码
          */
         $permanetCodeInfo = Service::getPermanentCodeInfo($suiteAccessToken, $tmpAuthCode);
     }
     Log::i("[Activate] getPermanentCodeInfo: " . json_encode($permanetCodeInfo));
     $permanetCode = $permanetCodeInfo->permanent_code;
     $authCorpId = $permanetCodeInfo->auth_corp_info->corpid;
     Log::i("[Activate] permanetCode: " . $permanetCode . ",  authCorpId: " . $authCorpId);
     /**
      * 获取企业access token
      */
     $corpAccessToken = Service::getCorpAccessToken($suiteAccessToken, $authCorpId, $permanetCode);
     Log::i("[Activate] getCorpToken: " . $corpAccessToken);
     /**
      * 获取企业授权信息
      */
     $res = Service::getAuthInfo($suiteAccessToken, $authCorpId, $permanetCode);
     Log::i("[Activate] getAuthInfo: " . json_encode($res));
     self::check($res);
     /**
      * 激活套件
      */
     $res = Service::activeSuite($suiteAccessToken, $authCorpId, $permanetCode);
     Log::i("[Activate] activeSuite: " . json_encode($res));
     self::check($res);
 }
Example #11
0
 public function display($source, $commands)
 {
     foreach ($commands as $value) {
         Log::i()->debug($source, $value["command"] . ": " . $value["result"]);
     }
 }
Example #12
0
 public function send_password_changed_notification_mail($username)
 {
     $message = '
         <html>
         <head>
           <title style="font-size:28px;">' . $this->subject . '</title>
         </head>
         <body style="background-color:#fff; color:#21acd7; border : 5px solid #21acd7;">
           <div style="border : 5px solid #21acd7; margin :0; padding :20px; text-align : centre;">
             <h2>Login Password Changed</h2>
           </div>
           <table style="border : 5px solid #21acd7; padding :20px; width: 100%;">
             <tr>
               <td>Login passoword of \'' . $username . '\' has been updated.' . "\n" . 'If you are not done this your system security is compromised.' . "\n" . 'Please contact your system admin immediatly.
               </td>
             </tr>
           </table>
         </body>
         </html>
         ';
     $headers = $this->header . "\r\n";
     $headers .= 'MIME-Version: 1.0' . "\r\n";
     $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
     $result = mail($this->to, $this->subject, $message, $headers);
     $description = "password changed notification mail has been sent, user name : {$username} ";
     Log::i($this->tag, $description);
     //saving to an html file
     //        $h = fopen("sample.html", "w");
     //        fwrite($h, $message);
     //        fclose($h);
 }
function login()
{
    global $user_id;
    $tag = 'LOG IN';
    $ch = curl_init(BASE_URL . 'login.php');
    $fields = array("user_name" => 'pos2', 'password' => '1234');
    curl_setopt($ch, CURLOPT_COOKIEJAR, COOKIE_FILE);
    curl_setopt($ch, CURLOPT_COOKIEFILE, COOKIE_FILE);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($fields));
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HEADER, FALSE);
    $content = curl_exec($ch);
    curl_close($ch);
    $json = json_decode($content, TRUE);
    echo "<hr/>LOGIN<br/>";
    print_r($json);
    echo "<hr/>";
    Log::i($tag, "Login Responce: " . multi_implode(" ", $json));
    $status = $json['status'];
    if ($status === "success") {
        $user_id = $json["data"]["user"]["id"];
        return TRUE;
    } else {
        return FALSE;
    }
}
Example #14
0
$msg = "";
$errCode = $crypt->DecryptMsg($signature, $timeStamp, $nonce, $encrypt, $msg);
if ($errCode == 0) {
    Log::i(json_encode($_GET) . "  " . $msg);
    $eventMsg = json_decode($msg);
    $eventType = $eventMsg->EventType;
    if ("suite_ticket" === $eventType) {
        Cache::setSuiteTicket($eventMsg->SuiteTicket);
    } else {
        if ("tmp_auth_code" === $eventType) {
            //handle temporary auth code
        } else {
            if ("change_auth" === $eventType) {
                //handle auth change event
            } else {
                //should never happen
            }
        }
    }
} else {
    Log::e(json_encode($_GET) . "  ERR:" . $errCode);
}
$plain = "success";
$encryptMsg = "";
$errCode = $crypt->EncryptMsg($plain, $timeStamp, $nonce, $encryptMsg);
if ($errCode == 0) {
    echo $encryptMsg;
    Log::i("RESPONSE: " . $encryptMsg);
} else {
    Log::e("RESPONSE ERR: " . $errCode);
}
             foreach ($sales_items_new as $sale_item_new) {
                 if ($item_id == $sale_item_new->item_id) {
                     $removed_item = false;
                 }
             }
             if ($removed_item) {
                 $qty = $sale_item_prev->quantity;
                 $inv = new inventry();
                 $inv->company_id = $sale->company_id;
                 $inv->item_id = $item_id;
                 $invs = $inv->getInventryForSpecificCompanyAndItem();
                 $inv = $invs[0];
                 $inv->in_stock_count = $inv->in_stock_count + $qty;
                 $inv->updateInventry();
                 $description = "Updating inventry (sales return - removed item) diff : " . $qty . ", inventry : " . $inv->to_string();
                 Log::i($tag, $description);
             }
         }
         $message = "Sale Updated Successfuly";
         $responce = array('status' => 'success', 'error' => '', 'data' => array("message" => $message, "id" => $sale->id));
     } else {
         $responce = array('status' => 'failed', 'error' => 'Data missing', 'data' => array());
     }
 } else {
     if ($form_id == 4) {
         // bank deposit edit
         if (isset($_POST['amount']) and !empty($_POST['amount']) and isset($_POST['bank_deposit_id']) and !empty($_POST['bank_deposit_id']) and isset($_POST['description']) and !empty($_POST['description'])) {
             $bank_deposit = new bank_deposits();
             $bank_deposit->id = $_POST['bank_deposit_id'];
             $bank_deposit->getBankDeposit();
             $bank_deposit->description = $_POST['description'];
 /**
  * 建立到服务器的网络连接
  * @access private
  * @return boolean
  */
 private function socket()
 {
     if (!function_exists("socket_create")) {
         $this->_errorMessage = "Extension sockets must be enabled";
         Log::i("*********************服务器必须是开启的");
         return false;
     }
     //创建socket资源
     $this->_socket = socket_create(AF_INET, SOCK_STREAM, getprotobyname('tcp'));
     if (!$this->_socket) {
         $this->_errorMessage = socket_strerror(socket_last_error());
         Log::i("*********************设置参数完成socket str错误");
         return false;
     }
     socket_set_block($this->_socket);
     //设置阻塞模式
     //连接服务器
     if (!socket_connect($this->_socket, $this->_sendServer, $this->_port)) {
         $this->_errorMessage = socket_strerror(socket_last_error());
         Log::i("*********************连接服务器错误");
         return false;
     }
     Log::i("*********************连接服务器成功");
     socket_read($this->_socket, 1024);
     return true;
 }
Example #17
0
<?php

//加载邮件类
require_once "libs/LogUtil.class.php";
require_once "libs/SendMail.class.php";
$name = $_POST["name"];
$address = $_POST["address"];
$mess = $_POST["mess"];
$content = "用户:{$name}<br/>邮箱地址:{$address}<br/>消息内容:{$mess}";
Log::i("********************开始发送");
$mail = new SendMail();
Log::i("*********************开始设置参数");
$mail->setServer("smtp.126.com", "*****@*****.**", "whlqyl040406081");
$mail->setFrom("*****@*****.**");
$mail->setReceiver("*****@*****.**");
$mail->setMailInfo("个人主页", "网站邮件", $content, "");
Log::i("*********************设置参数完成");
$result = $mail->startSendMail();
Log::i("**********************发送结果{$result}" . $mail->error());
echo "{'result':'{$result}'}";
Example #18
0
 protected function srv_return($info, $return_var)
 {
     switch ($return_var) {
         case 0:
             foreach ($info as $inf) {
                 Log::i()->debug(self::$me, "Return: " . $inf);
             }
             break;
         default:
             Log::i()->error(self::$me, "" . $info[0]);
             break;
     }
 }
Example #19
0
 function updateSale($sale = null)
 {
     if ($sale == null) {
         $sale = $this;
     }
     $sale_id = $this->id;
     $this->db_handler->update_model($sale);
     $sale_item_obj = new sales_items();
     $sale_item_obj->clearSaleItems($sale_id);
     if (is_array($this->sales_items) and count($this->sales_items) != 0) {
         foreach ($this->sales_items as $sales_item) {
             $sales_item->sale_id = $sale_id;
             $sales_item->company_id = $sale->company_id;
             $sales_item->addSaleItem();
         }
     }
     $description = "Updating Sale (" . $sale->to_string() . ")";
     Log::i($this->tag, $description);
 }
Example #20
0
 function addPurchace($purchace = null)
 {
     if ($purchace == null) {
         $purchace = $this;
     }
     $purchace_id = $this->db_handler->add_model($purchace);
     foreach ($this->purchace_items as $purchace_item) {
         $purchace_item->purchace_id = $purchace_id;
         $purchace_item->addPurchaceItem();
     }
     $description = "Added new Purchace (" . $purchace->to_string() . ")";
     Log::i($this->tag, $description);
 }
Example #21
0
 function deleteUser()
 {
     $result = $this->db_handler->delete_model($this);
     if ($result) {
         $description = "Customer deleted, Customer ID : " . $this->id;
         Log::i($this->tag, $description);
     }
     return $result;
 }