示例#1
0
 public function arhive()
 {
     try {
         $zip = new Zip();
         $res = array();
         foreach ($this->params->files as $n) {
             $file = BasefileModel::createFromPath($n, false);
             if ($file->type == 'folder') {
                 $this->arhiveRecursive($zip, $file, $file->name);
             } else {
                 $zip->addFile($file->getContent(), Lib::convert($file->name, Cfg::get('charset'), Cfg::get('charsetZip')), $file->ctime());
             }
             $res[] = $file;
         }
         $c = count($res);
         $name = 'arhive.zip';
         if ($c == 1) {
             $name = $res[0]->filename() . '.zip';
         }
         $zip->sendZip($name);
         exit;
     } catch (Exception $ex) {
         Log::exception($ex);
         echo gettext('Не возможно получить архив');
     }
     exit;
 }
示例#2
0
 /**
  * Декодировать объект согласно настройкам
  * @param Object $var
  * @return Object 
  */
 static function decode($var)
 {
     $charsetFrom = Cfg::get('charsetWeb', 'UTF-8');
     $charsetTo = Cfg::get('charset', 'cp1251');
     if ($charsetFrom && $charsetTo && $charsetFrom != $charsetTo) {
         $var = self::convert($var, $charsetFrom, $charsetTo);
     }
     return $var;
 }
示例#3
0
 private function __construct()
 {
     $cfg = Cfg::get('DB');
     if ($cfg['driver'] == 'mysql') {
         require_once 'SQL.class.php';
         self::$db = new SQL($cfg['host'], $cfg['login'], $cfg['password'], $cfg['base']);
     }
     if ($cfg['driver'] == 'pgsql') {
         require_once 'PgSQL.class.php';
         self::$db = new SQL($cfg['host'], $cfg['login'], $cfg['password'], $cfg['base']);
     }
 }
示例#4
0
 /**
  * @return PS
  */
 static function getInstance()
 {
     if (empty(self::$ps)) {
         if (!($paysystem = Cfg::get('PAYSYSTEM'))) {
             $paysystem = 'robokassa';
         }
         $rs = DB::select("SELECT * FROM sc_pay_system WHERE name='{$paysystem}'");
         if ($rs->next()) {
             $class_name = "PS" . ucfirst($paysystem);
             include_once "ps/{$class_name}.class.php";
             self::$ps = new $class_name($rs->get('config'));
         }
     }
     return self::$ps;
 }
示例#5
0
 private function __construct()
 {
     $levels = Cfg::get('log_level');
     if ($levels) {
         $levels = explode('|', $levels);
         $values = array('error' => self::ERROR, 'warning' => self::WARNING, 'info' => self::INFO, 'debug' => self::DEBUG);
         $this->level = 0;
         foreach ($levels as $v) {
             $v = trim($v);
             $this->level |= $values[$v];
         }
     }
     $this->dir = Cfg::get('log_dir', Cfg::get('log_dir'));
     //$this->_write(date('d.m.Y H:i'));
 }
示例#6
0
 public function initInfo()
 {
     parent::initInfo();
     $path = Cfg::get('baseDir') . $this->id;
     Log::debug($path);
     $this->lastmod = @filemtime($path);
     $this->size = sprintf("%u", filesize($path));
     if ($this->type != 'folder') {
         $pos = strrpos($this->name, ".");
         if ($pos) {
             $this->cls = substr($this->name, $pos + 1);
             $this->type = $this->getTypeFromExp($this->cls);
         }
     }
 }
function displayCatalog($catalog, $deep, $mod_uri)
{
    global $CONFIG, $offer, $count, $counts;
    foreach ($catalog as $item) {
        ?>
        <tr id="item<?php 
        echo $item['id'];
        ?>
">
            <td>
                <input name="item[]" value="<?php 
        echo $item['id'];
        ?>
" type="checkbox">

            </td>
            <td style="padding-left:<?php 
        echo $deep * 20;
        ?>
px;">

                <a href="<?php 
        echo $mod_uri;
        ?>
CatalogEdit/?id=<?php 
        echo $item['id'];
        ?>
">
                    <?php 
        echo $item['name'];
        ?>
</a>
            </td>
            <td><?php 
        echo $item['id'];
        ?>
</td>
            <td>
                <a href="<?php 
        echo $mod_uri;
        ?>
goods/?category=<?php 
        echo $item['id'];
        ?>
">
                    <?php 
        echo intval(@$offer['count'][$item['id']]);
        ?>
                </a>
                <?php 
        if (Cfg::get('GOODS_FIELD_CATALOGS')) {
            ?>
                    /<a href="<?php 
            echo $mod_uri;
            ?>
goods/?category=<?php 
            echo $item['id'];
            ?>
">
                        <?php 
            echo intval(@$offer['counts'][$item['id']]);
            ?>

                    </a>
                <?php 
        }
        ?>
            </td>
            <td><input name="sort[<?php 
        echo $item['id'];
        ?>
]" value="<?php 
        echo $item['sort'];
        ?>
" style="width:50px"></td>
            <td><input name="main_sort[<?php 
        echo $item['id'];
        ?>
]" value="<?php 
        echo $item['main_sort'];
        ?>
" style="width:50px"></td>
            <td>
                <input type="checkbox" name="export[]" value="<?php 
        echo $item['id'];
        ?>
" <?php 
        if ($item['export'] == 1) {
            ?>
checked<?php 
        }
        ?>
>
            </td>
            <td style="text-align:right">
                <a class="add_to" rel="<?php 
        echo $item['id'];
        ?>
" href="<?php 
        echo $mod_uri;
        ?>
CatalogEdit/?parent=<?php 
        echo $item['id'];
        ?>
"><img src="/img/pic/add_16.gif" title="Добавить подраздел" alt="Добавить подраздел"/></a>

                <a href="<?php 
        echo $mod_uri;
        ?>
CatalogEdit/?id=<?php 
        echo $item['id'];
        ?>
"><img src="/img/pic/edit_16.gif" title="Редактировать" alt="Редактировать"/></a>

                <a href="?act=onRemove&id=<?php 
        echo $item['id'];
        ?>
"><img src="/img/pic/trash_16.gif" title="Удалить" border="0" alt="" onclick="return confirm('Удалить <?php 
        echo $item['name'];
        ?>
?')"/></a>
            </td></tr><?php 
        if (isset($item['children'])) {
            displayCatalog($item['children'], $deep + 1, $mod_uri);
        }
    }
}
                <?php 
if (Cfg::get('GOODS_FIELD_AWARDS')) {
    ?>
                                		<tr><th>Агентское вознаграждение:</th><td><input class="input-text num2" name="awards"  value="<?php 
    echo $awards;
    ?>
"/></td></tr>
                <?php 
}
?>
		<tr><th>Новинка:</th><td><input class="input-text num" name="sort3"  value="<?php 
echo $sort3;
?>
"/></td></tr>
                <?php 
if (Cfg::get('GOODS_ACTION')) {
    ?>
	
                        <tr><th><a href="/admin/action/">Акция</a>:</th><td>
                                                        <select name="sort1">
                                                            <option value="0">--не выбран</option>
                                <?php 
    foreach ($actions as $itm) {
        ?>
                                                                                            <option value="<?php 
        echo $itm['id'];
        ?>
" <?php 
        if ($sort1 == $itm['id']) {
            ?>
selected<?php 
示例#9
0
        require_once $path;
    }
}
Cfg::init('../../config/config.yaml', new YamlCfgSource());
$directory = 'locale';
$domain = 'messages';
$locale = Cfg::get('lang', 'en_EN');
// Задаем текущий язык проекта
putenv("LANG=" . $locale);
// Задаем текущую локаль (кодировку)
setlocale(LC_ALL, $locale);
// Задаем каталог домена, где содержатся переводы
if (function_exists('bindtextdomain')) {
    bindtextdomain($domain, $directory);
    textdomain($domain);
    bind_textdomain_codeset($domain, Cfg::get('charset', 'UTF-8'));
} else {
    function gettext($text)
    {
        return $text;
    }
}
Log::debug('=====================================================================================================================================================');
Log::timer('app');
// Get Request
$request = new Request(array('restful' => false));
// Get Controller
require 'controllers/' . $request->controller . '.php';
$controller_name = ucfirst($request->controller) . 'Controller';
$controller = new $controller_name();
$ex = new PHP_Exceptionizer(E_ALL);
示例#10
0
 static function getLastView($limit = 20)
 {
     if (Cfg::get('SHOP_LAST_VIEW_LIMIT')) {
         $limit = (int) Cfg::get('SHOP_LAST_VIEW_LIMIT');
     }
     $res = array();
     if (!empty($_SESSION['__LAST_VIEW'])) {
         $arr = array_slice(array_reverse($_SESSION['__LAST_VIEW']), 0, $limit);
         $rs = DB::select("SELECT * FROM sc_shop_item i\n\t\t\t\tLEFT JOIN(SELECT COUNT(DISTINCT commentid) AS c,AVG(rating) AS r,itemid  FROM sc_comment,sc_comment_rait r \n\t\t\t\t\tWHERE commentid=id  AND TRIM(comment)<>'' AND status=1 AND type IN('','goods') GROUP BY itemid) AS rait ON rait.itemid=i.id\n\t\t\t\n\t\t\tWHERE  i.price>0 AND i.in_stock>0 AND i.id IN('" . implode("','", $arr) . "') LIMIT {$limit}");
         while ($rs->next()) {
             $res[$rs->get('id')] = $rs->getRow();
         }
         /* отсортируем */
         $tmp_res = array();
         foreach ($arr as $id) {
             if (!empty($res[$id])) {
                 $tmp_res[] = $res[$id];
             }
         }
         $res = $tmp_res;
     }
     return $res;
 }
示例#11
0
$rs = DB::select($q)->toArray();
if (!$rs) {
    exit;
}
ob_start();
include dirname(__FILE__) . "/catalog_subscribe.tpl.php";
$content = ob_get_contents();
ob_end_clean();
$type = 'catalog';
$mail = new Mail();
//	$mail->setFromMail($this->getConfig('mail'));
$mail->setFromMail(array(Cfg::get('SITE'), Cfg::get('mail')));
$mail->setTemplate('letter_catalog', array('FROM_SITE' => Cfg::get('SITE'), 'CONTENT' => $content));
$q = "SELECT distinct mail,id FROM sc_subscribe WHERE type LIKE '%" . $type . "%' \n\t\t\t\tAND NOT EXISTS(SELECT mailid FROM sc_news_sendlog WHERE id=mailid AND newsid={$id})";
$rs = DB::select($q);
$n = 0;
while ($rs->next()) {
    if (check_mail($m = trim($rs->get('mail')))) {
        $key = 'http://' . Cfg::get('SITE') . '/cabinet/unsubscribe/?key=' . md5($rs->get('mail') . $type . 'unsubscribe') . '&type=' . $type . '&mail=' . $rs->get('mail');
        $key = '<a href="' . $key . '">' . $key . '</a>';
        $mail->xsend($m, array('UNSUBSCRIBE' => $key));
        DB::insert('sc_news_sendlog', array('mailid' => $rs->get('id'), 'newsid' => $id));
        $n++;
    } else {
        DB::delete('sc_subscribe', "mail='" . SQL::slashes($rs->get('mail')) . "'");
    }
}
$rs = DB::select("SELECT MAX(create_time) AS m FROM sc_shop_proposal");
if ($rs->next()) {
    file_put_contents($last_time_fname, $rs->get('m'));
}
示例#12
0
\CoreWine\View\Engine::ini(PATH_APP . "/cache/views");
\CoreWine\DataBase\DB::connect($config['database']);
# Compile
\CoreWine\View\Engine::compile(PATH_APP, 'Resources/views');
foreach (\Kernel\Manager::$list as $name => $dir) {
    \CoreWine\View\Engine::compile(PATH_APP, "Resources/" . $name . "/views", $name);
}
\CoreWine\DataBase\ORM\SchemaBuilder::setFields(include PATH_CONFIG . '/orm.php');
# Load all sources
\Kernel\Manager::loadAll(PATH_SRC);
foreach (\Kernel\Manager::$list as $name => $dir) {
    \CoreWine\View\Engine::compile(PATH_SRC, $name . "/Resources/views", $name);
}
Cfg::set('app.drive.public', __DIR__ . "/../" . Cfg::get('app.public'));
Cfg::set('app.drive', __DIR__ . "/../");
# File Path
\CoreWine\DataBase\ORM\Field\File\Schema::setDefaultFilePath(Cfg::get('app.drive') . Cfg::get('app.public') . "uploads/");
# Web Path
\CoreWine\DataBase\ORM\Field\File\Schema::setDefaultWebPath(Cfg::get('app.web') . "uploads/");
\CoreWine\View\Engine::translates();
if (php_sapi_name() == "cli") {
    return;
}
\Kernel\Manager::callControllersRoutes();
\CoreWine\Http\Router::setRequest();
\Kernel\Manager::callControllersChecks();
$response = \CoreWine\Http\Router::load();
if (empty($response)) {
    die("Current Router must return a Response");
}
$response->send();
/catalog/goods/<?php 
    echo $row['id'];
    ?>
/">
	<img src="<?php 
    echo scaleImg($row['img'], 'w200h100');
    ?>
"><br>
	<?php 
    echo $row['name'];
    ?>
</a>
	</td>

<?php 
    if ($i && $i % 3 == 0) {
        ?>
</tr><tr><?php 
    }
}
?>
</tr>
</table>

<a href="http://<?php 
echo Cfg::get('SITE');
?>
/catalog/?last_time=<?php 
echo $last_date;
?>
">Все новинки на сайте</a>
示例#14
0
 static function mkdir($path, $name, $mode = false)
 {
     $path = trim($path, ' /\\');
     $pachFolder = Cfg::get('baseDir') . '/' . $path;
     $mode = intval(Cfg::get('mkdirmode', 0666, $mode), 8);
     if (mkdir($pachFolder . '/' . $name, $mode)) {
         chmod($pachFolder . '/' . $name, $mode);
         return BasefileModel::createFromPathAndName($path, $name);
     }
     return false;
 }
示例#15
0
    function display($data = array(), $tpl = null, $tplContainer = null, $cache = null)
    {
        global $ST;
        $this->setClientId();
        $this->setFirstReferer();
        $this->setRefId();
        if (!$tpl) {
            $tpl = $this->tplComponent;
        }
        if (!$tplContainer) {
            $tplContainer = $this->getTplContainer();
        }
        $this->refreshContainer();
        /* ceo */
        $rs = $ST->select("SELECT * FROM sc_ceo_meta\r\n\t\t\t WHERE \r\n\t\t\t \t(url='" . SQL::slashes($_SERVER['REQUEST_URI']) . "' AND rule='=') \r\n\t\t\t \tOR ('" . SQL::slashes($_SERVER['REQUEST_URI']) . "' LIKE CONCAT(url,'%') AND rule!='=' ) \r\n\t\t\t ORDER BY LENGTH(url) DESC LIMIT 1");
        /* ceo */
        $this->setCeo(array('url' => $_SERVER['REQUEST_URI']));
        if ($rs->next()) {
            $this->setCeo($rs->getRow());
            if ($this->getCeo('title')) {
                $this->setTitle($this->getCeo('title'));
            }
            if ($this->getCeo('header')) {
                $this->setHeader($this->getCeo('header'));
            }
            if ($this->getCeo('description')) {
                $this->setDescription($this->getCeo('description'));
            }
            if ($this->getCeo('keywords')) {
                $this->setKeywords($this->getCeo('keywords'));
            }
        }
        if (Cfg::get('STAMP')) {
            Img::$stamp = true;
        }
        $rnd = $this->render($data, $tpl);
        $out = $this->render($data, $tplContainer, $rnd);
        $t = microtime(true);
        if (preg_match_all('/\\{%(.+)%\\}/U', $out, $res) && $res) {
            $vals = array();
            foreach ($res[1] as $id => $key) {
                //07.09.2011 Возможность создавать содержимое по названию
                $tmp = '';
                if ($this->isAdmin()) {
                    $tmp = '<a href="/admin/content/?act=edit&name=' . trim($key) . '" class="coin-text-edit" title="Редактировать"></a>' . $res[0][$id];
                }
                $vals[trim($key)] = $tmp;
            }
            foreach ($this->cacheSelect("SELECT * FROM sc_content WHERE c_name IN('" . implode("','", array_keys($vals)) . "')", 0) as $row) {
                $res = $row['c_text'];
                if ($this->isAdmin()) {
                    $res = '<a href="/admin/content/?act=edit&name=' . $row['c_name'] . '" class="coin-text-edit" title="Редактировать"></a>' . $res;
                }
                $vals[$row['c_name']] = $res;
            }
            $out = preg_replace('/\\{%(.+)%\\}/Ue', '$vals[trim("\\1")]', $out);
            //_replace($keys[$rs->get('c_name')],$res,$out);
        }
        $this->visitLog();
        //Вывод
        ob_start();
        ob_implicit_flush(0);
        echo $out;
        global $begin_time, $query_count, $query_time, $query_report, $cache_time;
        $t = microtime(true) - $begin_time;
        ?>
<!-- <?php 
        echo $t;
        ?>
 --><!-- <?php 
        echo $query_count;
        ?>
 <?php 
        echo $query_time;
        ?>
 --><!-- <?php 
        echo $t - $query_time;
        ?>
 <?php 
        echo $cache_time;
        ?>
--><?php 
        ?>
<!-- <?php 
        echo isset($_GET['debug']) && $_GET['debug'] == 'true' ? $query_report : '';
        ?>
 --><?php 
        GzDocOut(3, isset($_GET['debug']) && $_GET['debug'] == 'true');
        $this->updateAdvView();
    }
示例#16
0
<div id="order">
    <h2>Оформить заявку</h2>

    <?php 
if (!$this->getUserId()) {
    ?>
        <?php 
    echo $this->getText('order_guest_comment');
    ?>
    <?php 
}
?>
    <table>
        <?php 
if (Cfg::get('SHOP_DELIVERY_ENABLED')) {
    ?>
            <tr>
                <td style="width:400px">
                    <h3>Укажите адрес доставки:</h3>
                </td>
                <td style="width:400px">
                    <h3>Дата и время доставки:
                        <div class="quest">
                            <?php 
    echo $this->getText('quest_date_time');
    ?>
                        </div>
                    </h3>
                </td>
                <td rowspan="2">
                    <?php 
示例#17
0
 static function findByDir($dir, $isInfo = true, $isHidden = true)
 {
     $hidden = false;
     if ($isHidden) {
         $hidden = Cfg::get('hidden', false);
     }
     $dir = ltrim($dir, '/');
     $path = Lib::gpath($dir);
     $res = array();
     $d = opendir($path);
     if ($d) {
         $files = array();
         while (($e = readdir($d)) !== false) {
             if ($e == '.' || $e == '..') {
                 continue;
             }
             if ($hidden == false || !preg_match($hidden, $e)) {
                 $file = BasefileModel::createFromPath($dir . '/' . $e, $isInfo);
                 if ($file) {
                     if ($file->type == 'folder') {
                         $res[] = $file;
                     } else {
                         $files[] = $file;
                     }
                 }
             }
         }
         $res = array_merge($res, $files);
     }
     return $res;
 }
示例#18
0
 function actSendOrder()
 {
     global $ST, $post;
     $basket = $this->getBasketInfo($post->get());
     if ($error = $this->checkOrder($post, $basket)) {
         echo printJSON(array('error' => $error));
         exit;
     } else {
         $address = $post->getString('address');
         /* Информация о заказчике */
         $data = array('phone' => $post->get('phone'));
         if ($city = $post->get('city')) {
             $data['city'] = $city;
         }
         if ($address) {
             $data['address'] = $address;
         }
         //Добавим реферала
         if ($refid = $post->getInt('refid')) {
             $rs = DB::select("SELECT * FROM sc_users WHERE u_id={$refid}");
             if ($rs->next()) {
                 $data['refid'] = $post->getInt('refid');
             } else {
                 //Если неправильный refid
             }
         }
         if (!$this->getUserId() && $post->getInt('reg') == 1) {
             //&& $post->exists('want_reg')
             if ($post->exists('mail')) {
                 $data['login'] = $post->get('mail');
                 $data['mail'] = $post->get('mail');
                 if ($post->exists('auto_pass')) {
                     //Всегда назначать пароль
                     $password = substr(md5(time()), 0, 6);
                     $data[] = "password=MD5('" . $password . "')";
                 } else {
                     $password = $post->get('password');
                     $data[] = "password=MD5('" . SQL::slashes($password) . "')";
                 }
                 if (!session_id()) {
                     session_set_cookie_params(3600 * 24 * 15, '/');
                     session_start();
                 }
                 $_SESSION['_USER']['u_id'] = $ST->insert('sc_users', $data, 'u_id');
                 //уведомление о регистрации
                 $this->sendTemplateMail($data['mail'], 'notice_new_user', array('FROM_SITE' => FROM_SITE, 'LOGIN' => $data['login'], 'PASSWORD' => $password));
                 //уведомление о регистрации админу
                 $this->sendTemplateMail($this->cfg('MAIL'), 'notice_new_user4admin', array('FROM_SITE' => FROM_SITE, 'LOGIN' => $data['login'], 'name' => $data['name']));
                 $this->noticeICQ($this->cfg('ICQ'), 'Новый пользователь на сайте');
             }
         } elseif ($this->getUserId()) {
             //Обновим пользователя
             if (!empty($basket['bonus'])) {
                 $data['bonus'] = $this->getUser('bonus') - $basket['bonus'];
                 $inc = array('userid' => $this->getUserId(), 'sum' => $basket['bonus'], 'balance' => $data['bonus'], 'type' => 'bonus', 'description' => 'Списание бонуса', 'time' => date('Y-m-d H:i:s'));
                 $ST->insert('sc_income', $inc);
             }
             $ST->update('sc_users', $data, 'u_id=' . $this->getUserId());
         }
         $this->setUser($data);
         $data = array('userid' => $this->getUserId(), 'fullname' => $this->getUser('name'), 'mail' => $post->get('mail') ? $post->get('mail') : $this->getUser('mail'), 'pay_system' => $post->get('pay_system'), 'phone' => $post->get('phone'), 'additionally' => $post->get('additionally'), 'price' => $basket['sum'], 'total_price' => $basket['total_sum'], 'order_status' => 0, 'pay_system' => $post->get('pay_system'), 'delivery' => $basket['delivery'], 'pay_bonus' => $basket['bonus'], 'discount' => $basket['discount'], 'margin' => $basket['margin']);
         if (Cfg::get("SHOP_DELIVERY_ENABLED")) {
             $data['date'] = $post->get('date') ? dte($post->get('date'), 'Y-m-d') : date('Y-m-d');
             $time = $post->getString('time');
             if ($t = $this->enum('sh_delivery_time', $time)) {
                 $time = $t;
             }
             $delivery_type = 1;
             //доставка курьером
             if ($post->getInt('delivery_type')) {
                 $delivery_type = $post->getInt('delivery_type');
             }
             if ($basket['delivery'] === false) {
                 //доставка не возможна
                 $delivery_type = 2;
             }
             $data['city'] = $address;
             $data['address'] = $post->get('city');
             $data['delivery_type'] = $delivery_type;
         }
         //			$order_data=array(
         //				'from_name'=>$post->get('from_name'),
         //				'from_phone'=>$post->get('from_phone'),
         //				'from_city'=>$post->get('from_city'),
         //				'remember'=>$post->get('remember'),
         //				'report'=>$post->get('report'),
         //				'call'=>$post->get('call'),
         //				'call_no_report'=>$post->get('call_no_report'),
         //			);
         //			$data['order_data']=printJSON($order_data);
         //			if(!trim($data['address'])){
         //					$data['address']=serialize(array(
         ////						'region'=>$post->get('region'),
         //						'city'=>$post->get('city'),
         //						'district'=>$post->get('district'),
         //						'street'=>$post->get('street'),
         //						'house'=>$post->get('house'),
         //						'flat'=>$post->get('flat'),
         //						'porch'=>$post->get('porch'),
         //						'floor'=>$post->get('floor'),
         //				));
         //
         //			}
         //Добавим заказ
         $id = LibShop::addOrder($data, $basket['basket']);
         if ($refid = $post->getInt('refid')) {
             ShopBonus::addRefAwards($refid, $basket['basket']);
         } elseif ($refid = ShopBonus::getPromoRefId($post->get('promo'))) {
             ShopBonus::addRefAwards($refid, $basket['basket']);
         }
         $ps_href = '';
         if (isset($data['pay_system']) && $data['pay_system'] == 3 && $data['total_price']) {
             //Если электронные платежи и есть сумма
             $rs1 = $ST->select("SELECT * FROM sc_pay_system WHERE name='paymaster'");
             if ($rs1->next()) {
                 include_once "core/lib/PSPaymaster.class.php";
                 $ps = new PSPaymaster(unserialize($rs1->get('config')));
                 $ps->setDesc('Покупка товара');
                 $ps->setSumm($data['total_price']);
                 $ps->setEmail($this->getUser('mail'));
                 $ps->setOrderNum($id);
                 $ps_href = $ps->getUrl();
             }
         }
         //            $icq_notice = "Новый заказ на сайте {$_SERVER['HTTP_HOST']}\n";
         //
         //
         //            $icq_notice.="Итого: {$basket['sum']}\n";
         //            $icq_notice.="Заказчик: {$post->get('from_name')}\n";
         //            $icq_notice.="Контактный телефон: {$post->get('from_phone')}\n";
         //            $icq_notice.="Адрес: {$post->get('address')}\n";
         ////			$icq_notice.="Сообщение: {$post->get('comment')}\n";
         //            $icq_notice.="Время доставки: {$post->get('date')} {$post->get('time')}\n";
         //уведомление о заказе пользователю
         $notice = $data;
         //+$order_data;
         if (!empty($notice['date'])) {
             $notice['date'] = dte($notice['date']);
         }
         //			$notice['description']='';
         //			foreach (array('remember','report','call','call_no_report',) as $v){
         //				$notice['description'].=$this->enum('field_label',@"{$v}_{$notice[$v]}")."<br>";
         //			}
         $notice['ps_href'] = '';
         if ($ps_href) {
             $notice['ps_href'] = "Для того, чтобы оплатить заказа перейдите по ссылке <a href=\"{$ps_href}\">ОПЛАТИТЬ</a>";
         }
         $delivery_list = $this->enum('sh_delivery_type');
         $pay_system_list = $this->enum('sh_pay_system');
         $notice['ORDER_NUM'] = $order_num = $id;
         //			$notice['ORDER_NUM']=$order_num;
         $notice['NAME'] = $this->getUser('name');
         $notice['FROM_SITE'] = FROM_SITE;
         $notice['basket'] = $this->render(array_merge($basket, array('is_order' => true, 'is_letter' => true)), dirname(__FILE__) . '/basket_content.tpl.php');
         $notice['delivery_type'] = @$delivery_list[$notice['delivery_type']];
         $notice['pay_system'] = @$pay_system_list[$notice['pay_system']];
         include 'function.tpl.php';
         if (!empty($notice['address'])) {
             $notice['address'] = parsAddr($notice['address']);
         }
         //			$url="http://{$_SERVER['HTTP_HOST']}/prnt/SHET/?id=$id&PHPSESSID=".session_id();
         //			$url="http://{$_SERVER['HTTP_HOST']}/prnt/SBER/?id=$id&PHPSESSID=".session_id();
         //			$content=file_get_contents($url);
         $att = array();
         if (isset($data['pay_system']) && $data['pay_system'] == 1) {
             $url = "http://{$_SERVER['HTTP_HOST']}/prnt/SBERpdf/?id={$id}";
             $notice['ps_href'] = "<a href=\"{$url}\">Распечатать счёт</a>";
             //				$att[]=array('name'=>'Счёт.xls','file'=>$url."&access=allow");
         }
         /* if($post->getInt('is_jur')){ //Печатать не надо
            $url="http://{$_SERVER['HTTP_HOST']}/prnt/SchetWord/?id=$id";
            $notice['ps_href']="<a href=\"{$url}\">Распечатать счёт</a>";
            $att[]=array('name'=>'na_oplatu'.date('Y_m_d').'.doc','file'=>$url."&access=allow");
            } */
         $mail = $post->exists('mail') ? $post->get('mail') : $this->getUser('mail');
         if ($mail) {
             $this->sendTemplateMail($post->get('mail'), 'notice_new_order', $notice, $att);
         }
         //уведомление о заказе админу
         //			$mail_contacts=$this->enum('mail_contacts',$this->getRegion());
         $this->sendTemplateMail($this->cfg('MAIL'), 'notice_new_order4admin', $notice);
         // $this->noticeICQ($this->cfg('ICQ'), $icq_notice);
         $d = $this->getOrderData();
         unset($d['additionally']);
         $this->saveOrderData($d);
         $this->saveBasketData(array());
         //			setcookie('basket',null,0,'/');//Очистим корзину
         Cookie::set('order_id', $id);
         $redirect_href = "/catalog/success/?id={$id}";
         if ($ps_href) {
             $redirect_href = $ps_href;
         }
         echo printJSON(array('id' => $id, 'order_num' => $order_num, 'error' => '', 'count' => $basket['count'], 'delivery' => $data['delivery'], 'total_price' => $data['total_price'], 'ps_href' => $notice['ps_href'], 'redirect_href' => $redirect_href, 'date' => "{$post->get('date')} {$post->get('time')}"));
         exit;
     }
 }