Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?class CSoftEffectPDF {
- function sendPDF($ID, $arFields) {
- global $USER;
- $module_id = "softeffect.pdf";
- $person = explode(",", COption::GetOptionString($module_id, "SE_TYPE_PERSON_IDS", ""));
- $pay = explode(",", COption::GetOptionString($module_id, "SE_PAY_SYSTEM_IDS", ""));
- if (in_array($arFields["PERSON_TYPE_ID"], $person) && in_array($arFields["PAY_SYSTEM_ID"], $pay)) {
- require_once $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/softeffect.pdf/classes/general/execute.php";
- }
- }
- function sendEmail($ID, &$eventName, &$arFields) {
- global $USER;
- $arOrder = CSaleOrder::GetByID($arFields["ORDER_ID"]);
- $module_id = "softeffect.pdf";
- $person = explode(",", COption::GetOptionString($module_id, "SE_TYPE_PERSON_IDS", ""));
- $pay = explode(",", COption::GetOptionString($module_id, "SE_PAY_SYSTEM_IDS", ""));
- if ((in_array($arOrder["PERSON_TYPE_ID"], $person) && in_array($arOrder["PAY_SYSTEM_ID"], $pay))) {
- return FALSE;
- }
- }
- //custom function
- function __AdmSettingsSaveOptionModify($module_id, $arOption)
- {
- $module_id = "softeffect.pdf";
- if(!is_array($arOption))
- return false;
- $arControllerOption = CControllerClient::GetInstalledOptions($module_id);
- if(isset($arControllerOption[$arOption[0]]))
- return false;
- $name = $arOption[0];
- $val = $_REQUEST[$name];
- if(array_key_exists(4, $arOption) && $arOption[4] == 'Y')
- {
- if($arOption[3][0] == 'checkbox')
- {
- $val = 'N';
- }
- else
- {
- return false;
- }
- }
- if($arOption[3][0] == "checkbox" && $val != "Y")
- $val = "N";
- if($arOption[3][0] == "multiselectbox")
- $val = @implode(",", $val);
- if($arOption[3][0] == "multidoubletext") {
- $name = $arOption[3][0];
- $val = serialize($_REQUEST[$name]);
- //echo "<pre>"; print_r($arOption); echo "</pre>";die();
- }
- COption::SetOptionString($module_id, $name, $val, $arOption[1]);
- }
- function __AdmListDrawRowModify($module_id, $Option)
- {
- $module_id = "softeffect.pdf";
- IncludeModuleLangFile(__FILE__);
- $arControllerOption = CControllerClient::GetInstalledOptions($module_id);
- $val = COption::GetOptionString($module_id, $Option[0], $Option[2]);
- $type = $Option[3];
- $Option[0] = $Option[0];
- $disabled = array_key_exists(4, $Option) && $Option[4] == 'Y' ? ' disabled' : '';
- $sup_text = array_key_exists(5, $Option) ? $Option[5] : '';
- if($type[0]=="multidoubletext") {
- $valText = COption::GetOptionString($module_id, $Option[0], $Option[2]);
- if($valText!=='') {
- $res.="<select name='templateLink'><option value='1'>".GetMessage("SELECT_TEMPLATE_S")."</option><option value='0'>".GetMessage("SELECT_TEMPLATE")."</option>";
- $arValue = unserialize($valText);
- $i=0;
- foreach($arValue as $arNameValueKey=>$arNameValue) {
- foreach($arNameValue as $arVal) {
- if($arNameValueKey=='Name' && ($arVal || $arValue[Value][$i])) {
- $res.="<option value='".htmlspecialchars($arValue[Value][$i])."|".$arValue[Album][$i]."|".$arValue[NameFile][$i]."'>".htmlspecialchars($arVal)."</option>";
- }
- $i++;
- }
- }
- $res.="</select>";
- return $res;
- }
- }
- }
- function __AdmSettingsDrawRowModify($module_id, $Option)
- {
- $module_id = "softeffect.pdf";
- IncludeModuleLangFile(__FILE__);
- $arControllerOption = CControllerClient::GetInstalledOptions($module_id);
- if(!is_array($Option)): ?>
- <tr class="heading">
- <td valign="top" colspan="2" align="center"><b><?=$Option?></b></td>
- </tr>
- <? else:
- $val = COption::GetOptionString($module_id, $Option[0], $Option[2]);
- $type = $Option[3];
- $Option[0] = $Option[0];
- $disabled = array_key_exists(4, $Option) && $Option[4] == 'Y' ? ' disabled' : '';
- $sup_text = array_key_exists(5, $Option) ? $Option[5] : '';
- ?>
- <tr>
- <td valign="top" width="60%"><?
- if($type[0]=="checkbox")
- echo "<label for='".htmlspecialchars($Option[0])."'>".$Option[1]."</label>";
- else
- echo $Option[1];
- if (strlen($sup_text) > 0)
- {
- ?><span class="required"><sup><?=$sup_text?></sup></span><?
- }
- ?></td>
- <td valign="middle" width="40%"><?
- if($type[0]=="checkbox"):
- ?><input type="checkbox" <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> id="<?echo htmlspecialchars($Option[0])?>" name="<?echo htmlspecialchars($Option[0])?>" value="Y"<?if($val=="Y")echo" checked";?><?=$disabled?>><?
- elseif($type[0]=="text"):
- ?><input type="text" <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> size="<?echo $type[1]?>" maxlength="255" value="<?echo htmlspecialchars($val)?>" name="<?echo htmlspecialchars($Option[0])?>"<?=$disabled?>><?
- elseif($type[0]=="selectbox"):
- $arr = $type[1];
- $arr_keys = array_keys($arr);
- ?><select name="<?echo htmlspecialchars($Option[0])?>" <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> <?=$disabled?>><?
- for($j=0; $j<count($arr_keys); $j++):
- ?><option value="<?echo $arr_keys[$j]?>"<?if($val==$arr_keys[$j])echo" selected"?>><?echo htmlspecialchars($arr[$arr_keys[$j]])?></option><?
- endfor;
- ?></select><?
- elseif($type[0]=="multiselectbox"):
- $arr = $type[1];
- $arr_keys = array_keys($arr);
- $arr_val = explode(",",$val);
- ?><select size="5" <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> multiple name="<?echo htmlspecialchars($Option[0])?>[]"<?=$disabled?>><?
- for($j=0; $j<count($arr_keys); $j++):
- ?><option value="<?echo $arr_keys[$j]?>"<?if(in_array($arr_keys[$j],$arr_val)) echo " selected"?>><?echo htmlspecialchars($arr[$arr_keys[$j]])?></option><?
- endfor;
- ?></select><?
- elseif($type[0]=="textarea"):
- ?><textarea <?if(isset($arControllerOption[$Option[0]]))echo ' disabled title="'.GetMessage("MAIN_ADMIN_SET_CONTROLLER_ALT").'"';?> rows="<?echo $type[1]?>" cols="<?echo $type[2]?>" name="<?echo htmlspecialchars($Option[0])?>"<?=$disabled?>><?echo htmlspecialchars($val)?></textarea><?
- elseif($type[0]=="multidoubletext"):
- ?>
- <div id="template">
- <table width="100%" cellpadding="3" cellspacing="0">
- <colgroup>
- <col width="25%" />
- <col width="25%" />
- <col width="25%" />
- <col width="25%" />
- </colgroup>
- <tbody id="template_table">
- <tr>
- <td><?=GetMessage("SE_MULTIDOUBLE_NAME")?></td>
- <td><?=GetMessage("SE_MULTIDOUBLE_VALUE")?></td>
- <td><?=GetMessage("SE_MULTIDOUBLE_NAMEFILE")?></td>
- <td><?=GetMessage("SE_MULTIDOUBLE_SCALE")?></td>
- </tr>
- <?
- $valText = COption::GetOptionString($module_id, $Option[0], $Option[2]);
- $arValue = unserialize($valText);
- if(
- isset($arValue['Name'][0]) && $arValue['Name'][0]!=='' ||
- isset($arValue['Value'][0]) && $arValue['Value'][0]!=='' ||
- isset($arValue['NameFile'][0]) && $arValue['NameFile'][0]!=='' ||
- isset($arValue['Album'][0]) && $arValue['Album'][0]!==''
- ) {
- $i=0;
- foreach($arValue as $arNameValueKey=>$arNameValue) {
- foreach($arNameValue as $arVal) {
- if($arNameValueKey=='Name' && ($arVal || $arValue['Value'][$i])) { ?>
- <tr class="tr_border">
- <td><input type="text" size="20" maxlength="255" value="<?=htmlspecialchars($arVal)?>" name="multidoubletext[<?=$arNameValueKey?>][]"<?=$disabled?> /></td>
- <td><input type="text" size="20" maxlength="255" value="<?=htmlspecialchars($arValue['Value'][$i])?>" name="multidoubletext[Value][]"<?=$disabled?> /></td>
- <td><input type="text" size="20" maxlength="255" value="<?=htmlspecialchars($arValue[NameFile][$i])?>" name="multidoubletext[NameFile][]"<?=$disabled?> /></td>
- <td><input type="checkbox" name="multidoubletext[Album][<?=$i?>]" <?=($arValue['Album'][$i] ? "checked='checked'" : NULL)?> id="Album<?=$i?>" /> <label for="Album<?=$i?>"><?=GetMessage("ALBUM_ORIENTATION")?></label></td>
- </tr>
- <? }
- $i++;
- }
- }
- } else { ?>
- <tr class="tr_border">
- <td><input type="text" size="20" maxlength="255" value="<?=htmlspecialchars($arVal)?>" name="multidoubletext[Name][]"<?=$disabled?> /></td>
- <td><input type="text" size="20" maxlength="255" value="<?=htmlspecialchars($arValue['Value'][$i])?>" name="multidoubletext[Value][]"<?=$disabled?> /></td>
- <td><input type="text" size="20" maxlength="255" value="<?=htmlspecialchars($arValue[NameFile][$i])?>" name="multidoubletext[NameFile][]"<?=$disabled?> /></td>
- <td><input type="checkbox" name="multidoubletext[Album][<?=$i?>]" <?=($arValue['Album'][$i] ? "checked='checked'" : NULL)?> id="Album<?=$i?>" /> <label for="Album<?=$i?>"><?=GetMessage("ALBUM_ORIENTATION")?></label></td>
- </tr>
- <? } ?>
- </tbody>
- </table>
- </div>
- <a href='javascript:void(0);' id='createTemplate' style="clear:both;display:block; float:left;" /><?=GetMessage("ADD_TEMPLATE");?></a>
- <script type="text/javascript">
- i = 0;
- window.onload = function() {
- var link = document.getElementById("createTemplate");
- link.onclick = function () {
- i = i+1;
- var divT = document.getElementById('template_table');
- html = '<tr class="tr_border"><td><input type="text" size="20" maxlength="255" value="" name="<?=htmlspecialchars($type[0])?>[Name][]"<?=$disabled?> /></td><td><input type="text" size="20" maxlength="255" value="" name="<?=htmlspecialchars($type[0])?>[Value][]"<?=$disabled?> /></td><td><input type="text" size="20" maxlength="255" value="" name="<?=htmlspecialchars($type[0])?>[NameFile][]"<?=$disabled?> /></td><td><input type="checkbox" name="multidoubletext[Album][]" id="Album'+i+'" /> <label for="Album'+i+'"><?=GetMessage("ALBUM_ORIENTATION")?></label></td></tr>';
- divT.innerHTML = divT.innerHTML + html;
- }
- }
- </script>
- <?
- endif;
- ?></td>
- </tr>
- <?
- endif;
- }
- function ShowParamsHTMLByArray($arParams) {
- foreach($arParams as $Option) {
- CSoftEffectPDF::__AdmSettingsDrawRowModify("softeffect.pdf", $Option);
- }
- }
- function MyOnAdminListDisplay(&$list) {
- IncludeModuleLangFile(__FILE__);
- if ($list->table_id == "tbl_sale_order") {
- $list->arActions["st_template"] = GetMessage("PDF_SEND_TEMPLATE");
- $module_id = "softeffect.pdf";
- CModule::AddAutoloadClasses(
- $module_id,
- array(
- 'CSoftEffectPDF' => 'classes/general/CSoftEffectPDF.php',
- )
- );
- $Option = COption::GetOptionString($module_id, "multidoubletext", "");
- $Option = CSoftEffectPDF::__AdmListDrawRowModify($module_id,Array("multidoubletext", "","",Array('multidoubletext',$Option)));
- $strIBlocksCp = "<div id='template_send' style='display:none;'>".$Option."</div><input type='hidden' name='table_id' value='tbl_sale_order' />";
- $list->arActions['st_template_chooser'] = array('type' => 'html', 'value' => $strIBlocksCp);
- $list->arActionsParams['select_onchange'] .= "BX('template_send').style.display = (this.value == 'st_template'? 'block':'none');";
- }
- }
- function OnBeforePrologHandler() {
- global $APPLICATION;
- global $DB;
- global $USER;
- if ($_REQUEST['action'] == "st_template" && $_REQUEST['templateLink'] && $_REQUEST["table_id"]=="tbl_sale_order") {
- if (!empty($_REQUEST['ID'])) {
- require_once $_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/softeffect.pdf/classes/general/mail_attach.php";
- CModule::IncludeModule("sale");
- CModule::IncludeModule("main");
- $url='http://saas.softcliens.tmweb.ru/pdf/curl.php';
- foreach ($_REQUEST['ID'] as $arID) {
- $ar_sales = CSaleOrder::GetByID($arID);
- $rsSites = CSite::GetByID($ar_sales["LID"]);
- $arSite = $rsSites->Fetch();
- $module = CModule::IncludeModuleEx('softeffect.pdf');
- $namePDF = 'invoice_'.(int)$arID.'.pdf';
- if ($module==2) {
- $namePDF = 'invoice_'.(int)$order_id.'_softeffect.ru_DEMO_MODE.pdf';
- } elseif ($module==3) {
- $namePDF = 'invoice_'.(int)$order_id.'_DEMO_IS_OVER_buy_module_in_softeffect.ru.pdf';
- }
- $filePath = $_SERVER['DOCUMENT_ROOT'].'/upload/softeffect.pdf/'.$namePDF;
- if(is_array($ar_sales)) {
- $ar_user = CUser::GetByID($ar_sales["USER_ID"]);
- $ar_user = $ar_user->Fetch();
- $userMail = $ar_user["EMAIL"];
- $html = "";
- $strOrderList = "";
- $dbBasketItems = CSaleBasket::GetList(
- array("NAME" => "ASC"),
- array("ORDER_ID" => $arID),
- false,
- false,
- array("ID", "NAME", "QUANTITY")
- );
- while ($arBasketItems = $dbBasketItems->Fetch()) {
- $strOrderList .= $arBasketItems["NAME"]." - ".$arBasketItems["QUANTITY"]." ".GetMessage("SOA_SHT");
- $strOrderList .= "\n";
- }
- $arFieldsMail = Array(
- "ORDER_ID" => $arID,
- "ORDER_DATE" => Date($DB->DateFormatToPHP(CLang::GetDateFormat("SHORT", SITE_ID))),
- "ORDER_USER" => $ar_user["NAME"]." ".$ar_user["LAST_NAME"],
- "PRICE" => SaleFormatCurrency($ar_sales["PRICE"], $ar_sales["CURRENCY"]),
- "BCC" => COption::GetOptionString("sale", "order_email", "order@".$SERVER_NAME),
- "EMAIL" => $userMail,
- "ORDER_LIST" => $strOrderList,
- "SALE_EMAIL" => COption::GetOptionString("sale", "order_email", "order@".$SERVER_NAME)
- );
- $module_id = "softeffect.pdf";
- $strPay = COption::GetOptionString($module_id, "SE_PAY_SYSTEM_IDS", "");
- $arPay = explode(",",$strPay);
- $paySystem = 0;
- foreach($arPay as $payVal){
- if($payVal==$ar_sales["PAY_SYSTEM_ID"]) { $paySystem = 1; }
- }
- //esli schet
- if($_REQUEST["templateLink"] == 1) {
- $album_orientation = COption::GetOptionString($module_id, "ALBUM_ORIENTATION", "");
- $_REQUEST["ORDER_ID"] = $arID;
- $_REQUEST["USER_ID"] = $ar_sales["USER_ID"];
- define('ETC_EXECUTE_COMPONENT', true);
- if($paySystem) {
- ob_start();
- $APPLICATION->IncludeComponent(
- "softeffect:sale.order.payment",
- "",
- array()
- );
- $html = ob_get_contents();
- ob_end_clean();
- var_dump($html);
- if ($module==3) {
- $html = '<html><body><div style="color: red; text-align: justify;">DEMO IS OVER! DEMO IS OVER! DEMO IS OVER!</div></body></html>';
- }
- $postfields = array("html" => str_replace(array("src='","src=\"", "href='/", "href=\"/"),
- array("src='http://".$_SERVER["SERVER_NAME"],"src=\"http://".$_SERVER["SERVER_NAME"], "href='http://".$_SERVER["SERVER_NAME"]."/","href=\"http://".$_SERVER["SERVER_NAME"]."/"),$html), "charset" => $arSite["CHARSET"],"landscape" => $album_orientation);
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
- $result = curl_exec($ch);
- curl_close($ch);
- file_put_contents($filePath, $result);
- chmod($filePath, 0777);
- SendAttache("SALE_NEW_ORDER", $ar_sales["LID"], $arFieldsMail, $filePath);
- } else {
- CEvent::Send("SALE_NEW_ORDER", $ar_sales["LID"], $arFieldsMail);
- }
- } else {
- $arParam = explode("|",$_REQUEST['templateLink']);
- if($arParam[2]){
- $namePDF = $arParam[2].'_'.(int)$arID.'.pdf';
- $filePath = $_SERVER['DOCUMENT_ROOT'].'/upload/softeffect.pdf/'.$namePDF;
- }
- if (file_exists($_SERVER["DOCUMENT_ROOT"].$arParam[0])) {
- $htm = curl_init();
- $postfieldsHtml = array("ORDER_ID"=>$arID);
- curl_setopt($htm, CURLOPT_URL,$_SERVER["SERVER_NAME"].$arParam[0]);
- curl_setopt($htm, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($htm, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($htm, CURLOPT_POST, 1);
- curl_setopt($htm, CURLOPT_POSTFIELDS, $postfieldsHtml);
- $html = curl_exec($htm);
- curl_close($htm);
- if ($module==3) {
- $html = '<html><body><div style="color: red; text-align: justify;">DEMO IS OVER! DEMO IS OVER! DEMO IS OVER!</div></body></html>';
- }
- $postfields = array("html" => str_replace(array("src='","src=\"", "href='/", "href=\"/"),
- array("src='http://".$_SERVER["SERVER_NAME"],"src=\"http://".$_SERVER["SERVER_NAME"],
- "href='http://".$_SERVER["SERVER_NAME"]."/","href=\"http://".$_SERVER["SERVER_NAME"]."/"),$html),
- "charset" => $arSite["CHARSET"],
- "landscape" => $arParam[1]
- );
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL,$url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $postfields);
- $result = curl_exec($ch);
- curl_close($ch);
- file_put_contents($filePath, $result);
- chmod($filePath, 0777);
- SendAttache("SEND_FILE_USER", $ar_sales["LID"], $arFieldsMail, $filePath);
- }
- }
- @unlink($filePath);
- }
- }
- }
- }
- }
- }?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement