Пример #1
0
 function _order_edit()
 {
     global $objDatabase, $_ARRAYLANG, $_CONFIG;
     $this->objTemplate->loadTemplateFile('module_gov_order_edit.html');
     $this->_pageTitle = $_ARRAYLANG['TXT_ORDER_EDIT'];
     $order_id = isset($_REQUEST['id']) ? $_REQUEST['id'] : 0;
     $productId = EgovLibrary::GetOrderValue('order_product', $order_id);
     $FieldName = $FieldValue = NULL;
     if (isset($_REQUEST['update'])) {
         $query = "\n                UPDATE " . DBPREFIX . "module_egov_orders\n                   SET order_state=" . $_REQUEST['state'] . "\n                 WHERE order_id={$order_id}\n            ";
         if ($objDatabase->Execute($query)) {
             $this->_strOkMessage = $_ARRAYLANG['TXT_STATE_UPDATED_SUCCESSFUL'];
         }
         $query = "\n                SELECT *\n                  FROM " . DBPREFIX . "module_egov_orders\n                 WHERE order_id={$order_id}";
         $objResult = $objDatabase->Execute($query);
         if (EgovLibrary::GetProduktValue('product_per_day', $productId) == 'yes') {
             $act = 1;
             if (intval($_REQUEST['state']) == 2 || intval($_REQUEST['state']) == 0) {
                 $act = 0;
             }
             $query = "UPDATE " . DBPREFIX . "module_egov_product_calendar\n                     SET calendar_act={$act}\n                     WHERE calendar_order={$order_id}";
             $objDatabase->Execute($query);
         }
         if (isset($_REQUEST['ChangeStateMessage'])) {
             $SubjectText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(EgovLibrary::GetProduktValue('product_name', $productId)), $_REQUEST['email_subject']);
             $SubjectText = html_entity_decode($SubjectText);
             $FormValue4Mail = '';
             $GSdata = explode(";;", $objResult->fields['order_values']);
             for ($y = 0; $y < count($GSdata); ++$y) {
                 if (!empty($GSdata[$y])) {
                     list($FieldName, $FieldValue) = explode('::', $GSdata[$y]);
                     if ($FieldName != '') {
                         $FormValue4Mail .= $FieldName . ': ' . $FieldValue;
                     }
                 }
             }
             $BodyText = str_replace('[[ORDER_VALUE]]', $FormValue4Mail, $_REQUEST['email_text']);
             $BodyText = str_replace('[[PRODUCT_NAME]]', html_entity_decode(EgovLibrary::GetProduktValue('product_name', $productId)), $BodyText);
             $BodyText = html_entity_decode($BodyText);
             $FromEmail = EgovLibrary::GetProduktValue('product_sender_email', $productId);
             if ($FromEmail == '') {
                 $FromEmail = EgovLibrary::GetSettings('set_sender_email');
             }
             $FromName = EgovLibrary::GetProduktValue('product_sender_name', $productId);
             if ($FromName == '') {
                 $FromName = EgovLibrary::GetSettings('set_sender_name');
             }
             $TargetMail = isset($_REQUEST['email']) ? $_REQUEST['email'] : '';
             if ($TargetMail == '') {
                 $TargetMail = EgovLibrary::GetEmailAdress($order_id);
             }
             if ($TargetMail != '') {
                 if (@(include_once ASCMS_LIBRARY_PATH . '/phpmailer/class.phpmailer.php')) {
                     $objMail = new \phpmailer();
                     if ($_CONFIG['coreSmtpServer'] > 0) {
                         if (($arrSmtp = \SmtpSettings::getSmtpAccount($_CONFIG['coreSmtpServer'])) !== false) {
                             $objMail->IsSMTP();
                             $objMail->Host = $arrSmtp['hostname'];
                             $objMail->Port = $arrSmtp['port'];
                             $objMail->SMTPAuth = true;
                             $objMail->Username = $arrSmtp['username'];
                             $objMail->Password = $arrSmtp['password'];
                         }
                     }
                     $objMail->CharSet = CONTREXX_CHARSET;
                     $objMail->SetFrom($FromEmail, $FromName);
                     $objMail->Subject = $SubjectText;
                     $objMail->Priority = 3;
                     $objMail->IsHTML(false);
                     $objMail->Body = $BodyText;
                     $objMail->AddAddress($TargetMail);
                     // TODO: Verify the result and show an error if sending the mail fails!
                     $objMail->Send();
                 }
             }
         }
     }
     $query = "\n            SELECT *\n              FROM " . DBPREFIX . "module_egov_orders\n             WHERE order_id=" . intval($_REQUEST['id']);
     $objResult = $objDatabase->Execute($query);
     if (!$objResult || $objResult->RecordCount() != 1) {
         \Cx\Core\Csrf\Controller\Csrf::header('Location: index.php?cmd=Egov&err=Wrong Order ID');
         exit;
     }
     $mailBody = EgovLibrary::GetProduktValue('product_target_body', $productId);
     $this->objTemplate->setGlobalVariable($_ARRAYLANG);
     $this->objTemplate->setVariable(array('SETTINGS_STATE_CHANGE_EMAIL' => $mailBody, 'ORDER_ID' => $objResult->fields["order_id"], 'ORDER_IP' => $objResult->fields["order_ip"], 'ORDER_DATE' => $objResult->fields["order_date"], 'ORDER_PRODUCT' => EgovLibrary::GetProduktValue('product_name', $objResult->fields['order_product']), 'STATE_SUBJECT' => EgovLibrary::GetSettings("set_state_subject"), 'EGOV_TARGET_EMAIL' => EgovLibrary::GetEmailAdress($order_id), 'EGOV_ORDER_STATUS_MENUOPTIONS' => EgovManager::getStatusMenuOptions($objResult->fields['order_state'])));
     // form falues
     $GSdata = explode(';;', $objResult->fields['order_values']);
     $y = 0;
     foreach ($GSdata as $value) {
         if (empty($value)) {
             continue;
         }
         list($FieldName, $FieldValue) = explode('::', $value);
         $this->objTemplate->setVariable(array('ROWCLASS' => ++$y % 2 ? 'row2' : 'row1', 'DATA_FIELD' => $FieldName, 'DATA_VALUE' => $FieldValue));
         $this->objTemplate->parse('orders_data_row');
     }
 }