コード例 #1
0
 public function store()
 {
     $promotion = new promotion();
     $promotion->project_id = Auth::user()->curr_project_id;
     $promotion->name = Input::get('name');
     $promotion->description = Input::get('description');
     $promotion->discount = Input::get('discount');
     $promotion->nominal = Input::get('nominal');
     $promotion->last_valid = Input::get('last_valid');
     $promotion->save();
     Session::flash('message', 'Sukses menambahkan promo baru');
 }
コード例 #2
0
ファイル: promotion.php プロジェクト: RenzcPHP/3dproduct
 /**
  *生成树 
  */
 public static function generate_tree($categories, $level_depth, $pid, $category, $category_field, $checkAll)
 {
     $tree = '';
     //设定标识
     static $related = '';
     static $mark_tree = 0;
     if ($related != $category) {
         $related = $category;
         $mark_tree = 0;
     }
     if ($mark_tree == 0) {
         $tree .= '<tr style="text-align:left;">
                     <th style="text-align:left;width:40px;padding-left:4px"><input type="checkbox" name="' . $checkAll . '" id="' . $checkAll . '" /></th>';
         if (isset($category_field)) {
             foreach ($category_field as $field) {
                 $tree .= '<th style="text-align:left">' . $field . '</th>';
             }
         }
         $tree .= '</tr>';
         $mark_tree++;
     }
     foreach ($categories[$level_depth] as $value) {
         $mark_pic = 0;
         $nbsp = '';
         for ($i = 1; $i < $level_depth; $i++) {
             $nbsp .= '&nbsp;&nbsp;&nbsp;&nbsp;';
         }
         if ($value['pid'] == $pid) {
             $tree .= '<tr style="text-align:left;">
                        <td>
                           <input name="' . $category . '[]" type="checkbox" value="' . $value['id'] . '" title="' . $value['title_manage'] . '"/>
                           <input type="hidden" name="parentId" value="' . $value['pid'] . '"/>
                        </td>';
             if (isset($category_field)) {
                 foreach ($category_field as $key => $field) {
                     $tree .= '<td>';
                     if ($mark_pic == 0) {
                         $tree .= $nbsp . '<img src="/images/icon_dot2.gif" class="icon_dot"  />';
                         $mark_pic++;
                     }
                     $tree .= $value[$key] . '</td>';
                 }
             }
             $tree .= '</tr>';
             if (isset($categories[$level_depth + 1])) {
                 $tree .= promotion::generate_tree($categories, $level_depth + 1, $value['id'], $category, $category_field, $checkAll);
             }
         }
     }
     return $tree;
 }
コード例 #3
0
ファイル: promotion.php プロジェクト: RenzcPHP/3dproduct
 public function edit()
 {
     role::check('promotion_promotion');
     // 收集请求数据
     $request_data = $this->input->get();
     $promotion = Mypromotion::instance($request_data['id'])->get();
     if (!$promotion['id']) {
         remind::set(Kohana::lang('o_global.bad_request'), request::referrer(), 'error');
     }
     $promotion['money_from'] = sprintf('%.3f', $promotion['money_from']);
     $promotion['money_to'] = sprintf('%.3f', $promotion['money_to']);
     $pmts_id = $promotion['pmts_id'];
     $scheme = Mypromotion_scheme::instance($promotion['pmts_id'])->get();
     //实例化session
     $session = Session::instance();
     // 模板输出
     $this->template->content = new View("promotion/edit_promotion_" . $pmts_id);
     //echo $pmts_id;
     //extra process needed for IDs
     switch ($pmts_id) {
         case 1:
             // discount_category
             $request_struct = array('where' => array(), 'orderby' => array('title_manage' => 'ASC'));
             $all_ids = CategoryService::get_instance()->index($request_struct);
             unset($all_ids['count']);
             //dialog start
             $this->template->content->dialog = new View("promotion/partial/dialog_category");
             $this->template->content->dialog->related_ids_name = 'related_ids';
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->dialog->related_ids = explode(',', $promotion['related_ids']);
             }
             $categoryDiaStruct = array('dialog_form' => 'dialog-form', 'categoryTable' => 'categoryTable');
             $this->template->content->dialog->categoryDiaStruct = $categoryDiaStruct;
             //显示字段设置
             $category_field = array("title_manage" => "中文名称", "title" => "分类名");
             $all_ids = promotion::convert($all_ids);
             $tree = promotion::generate_tree($all_ids, 1, 0, 'related_ids', $category_field, 'checkAll');
             $this->template->content->dialog->tree = $tree;
             //dialog end
             break;
         case 5:
             // get_gifts_buy_anything
         // get_gifts_buy_anything
         case 6:
             // get_gifts_price_morethan
             $request_struct = array('where' => array('type' => ProductService::PRODUCT_TYPE_GOODS, 'on_sale' => 1), 'orderby' => array('title' => 'ASC'));
             $all_ids = ProductService::get_instance()->index($request_struct);
             $this->template->content->goods_area = new View("promotion/partial/edit_goods");
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->goods_area->gift_related_ids = explode(',', $promotion['gift_related_ids']);
             }
             $this->template->content->goods_area->thing = 'goods';
             $this->template->content->thing = 'goods';
             $this->template->content->goods_area->all_ids = $all_ids;
             $this->template->content->all_ids = $all_ids;
             //dialog start
             $this->template->content->dialog = new View("promotion/partial/dialog_good");
             $goodDiaStruct = array('dialog_form' => 'dialog-form-good', 'goodSearchType' => 'goodSearchType', 'goodKeyword' => 'goodKeyword', 'goodSearchbtn' => 'goodSearchbtn', 'goodTable' => 'goodTable', 'checkAll' => 'checkAll', 'goods' => 'goods');
             $this->template->content->dialog->goodDiaStruct = $goodDiaStruct;
             $this->template->content->dialog->all_ids = $all_ids;
             //显示字段设置
             $js_good_field = 'var good_field = {\'SKU\':"sku","货品名":"title"};';
             $good_field = array('sku' => 'SKU', "title" => "货品名");
             $this->template->content->js_good_field = $js_good_field;
             $this->template->content->goods_area->good_field = $good_field;
             //dialog end
             break;
         case 2:
             // discount_product_during
         // discount_product_during
         case 3:
             // discount_product_quantity_morethan
         // discount_product_quantity_morethan
         case 12:
             // discount_cart_buy_product
         // discount_cart_buy_product
         case 16:
             // free_shipping_buy_product
             $this->template->content->products_area = new View("promotion/partial/edit_products");
             if ($session->get('sessionErrorData') === false) {
                 $related_ids = explode(',', trim($promotion['related_ids'], ','));
                 //                $this->template->content->products_area->related_ids = $related_ids;
             } else {
                 $related_ids = $session->get('sessionErrorData');
                 $related_ids = $related_ids['related_ids'];
             }
             $all_ids = ProductService::get_instance()->index(array('where' => array('on_sale' => 1, 'id' => $related_ids), 'orderby' => array('name_manage' => 'ASC')));
             $this->add_category_name($all_ids);
             $this->template->content->products_area->all_ids = $all_ids;
             $this->template->content->all_ids = $all_ids;
             $this->template->content->products_area->thing = 'products';
             $this->template->content->thing = 'products';
             //dialog start
             $this->template->content->dialog = new View("promotion/partial/dialog_product");
             $productDiaStruct = array('dialog_form' => 'dialog-form-product', 'productSearchType' => 'productSearchType', 'productKeyword' => 'productKeyword', 'productSearchbtn' => 'productSearchbtn', 'productTable' => 'productTable', 'checkAll' => 'checkAll', 'products' => 'products');
             $this->template->content->dialog->productDiaStruct = $productDiaStruct;
             $this->template->content->dialog->all_ids = $all_ids;
             //显示字段设置
             $js_product_field = 'var product_field = {\'SKU\':"sku","中文名称":"name_manage","商品名称":"title","分类名称":"category_name"};';
             $product_field = array('sku' => 'SKU', "name_manage" => "中文名称", "title" => "商品名称", "category_name" => "分类名称");
             $this->template->content->js_product_field = $js_product_field;
             $this->template->content->products_area->product_field = $product_field;
             //dialog end
             break;
         case 7:
             // get_gifts_product_price_morethan
             $this->template->content->products_area = new View("promotion/partial/edit_products");
             if ($session->get('sessionErrorData') === false) {
                 $related_ids = explode(',', trim($promotion['related_ids'], ','));
                 $this->template->content->products_area->related_ids = $related_ids;
             } else {
                 $related_ids = $session->get('sessionErrorData');
                 $related_ids = $related_ids['related_ids'];
             }
             $all_ids = ProductService::get_instance()->index(array('where' => array('on_sale' => 1, 'id' => $related_ids), 'orderby' => array('name_manage' => 'ASC')));
             $this->add_category_name($all_ids);
             $this->template->content->products_area->all_ids = $all_ids;
             $this->template->content->products_area->thing = 'products';
             $this->template->content->thing = 'products';
             $this->template->content->product_all_ids = $all_ids;
             //dialog start
             $this->template->content->dialog_product = new View("promotion/partial/dialog_product");
             $productDiaStruct = array('dialog_form' => 'dialog-form-product', 'productSearchType' => 'productSearchType', 'productKeyword' => 'productKeyword', 'productSearchbtn' => 'productSearchbtn', 'productTable' => 'productTable', 'checkAll' => 'checkAll', 'products' => 'products');
             $this->template->content->dialog_product->productDiaStruct = $productDiaStruct;
             $this->template->content->productDiaStruct = $productDiaStruct;
             $this->template->content->dialog_product->all_ids = $all_ids;
             //显示字段设置
             $js_product_field = 'var product_field = {\'SKU\':"sku","中文名称":"name_manage","商品名称":"title","分类名称":"category_name"};';
             $product_field = array('sku' => 'SKU', "name_manage" => "中文名称", "title" => "商品名称", "category_name" => "分类名称");
             $this->template->content->js_product_field = $js_product_field;
             $this->template->content->products_area->product_field = $product_field;
             //dialog end
             $this->template->content->goods_area = new View("promotion/partial/edit_goods");
             $this->template->content->goods_area->thing = 'goods';
             $this->template->content->thing = 'goods';
             $all_ids = ProductService::get_instance()->index(array('where' => array(), 'orderby' => array('title' => 'ASC')));
             $this->template->content->goods_area->all_ids = $all_ids;
             $this->template->content->good_all_ids = $all_ids;
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->goods_area->gift_related_ids = explode(',', $promotion['gift_related_ids']);
             }
             //dialog start
             $this->template->content->dialog_good = new View("promotion/partial/dialog_good");
             $goodDiaStruct = array('dialog_form' => 'dialog-form-good', 'goodSearchType' => 'goodSearchType', 'goodKeyword' => 'goodKeyword', 'goodSearchbtn' => 'goodSearchbtn', 'goodTable' => 'goodTable', 'checkAll' => 'checkAll', 'goods' => 'goods');
             $this->template->content->dialog_good->goodDiaStruct = $goodDiaStruct;
             $this->template->content->dialog_good->all_ids = $all_ids;
             //显示字段设置
             $js_good_field = 'var good_field = {\'SKU\':"sku","货品名":"title"};';
             $good_field = array('sku' => 'SKU', "title" => "货品名");
             $this->template->content->js_good_field = $js_good_field;
             $this->template->content->goods_area->good_field = $good_field;
             //dialog end
             break;
         case 8:
             // get_1_buy_n
             break;
         case 9:
             // get_another_cat_buy_cat
             $this->template->content->related_ids = explode(',', $promotion['related_ids']);
             $request_struct = array('where' => array(), 'orderby' => array('title_manage' => 'ASC'));
             $all_ids = CategoryService::get_instance()->index($request_struct);
             //dialog start
             $this->template->content->dialog = new View("promotion/partial/dialog_category");
             $this->template->content->dialog->related_ids_name = 'related_ids';
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->dialog->related_ids = explode(',', $promotion['related_ids']);
             }
             $categoryDiaStruct = array('dialog_form' => 'dialog-form', 'categoryTable' => 'categoryTable');
             $this->template->content->dialog->categoryDiaStruct = $categoryDiaStruct;
             $this->template->content->dialog->all_ids = $all_ids;
             $category_field = array("title_manage" => "中文名称", "title" => "分类名");
             $all_ids = promotion::convert($all_ids);
             $tree = promotion::generate_tree($all_ids, 1, 0, 'related_ids', $category_field, 'checkAll');
             $this->template->content->dialog->tree = $tree;
             //dialog end
             //dialog start
             $this->template->content->dialog_gift = new View("promotion/partial/dialog_category");
             $this->template->content->dialog_gift->related_ids_name = 'gift_related_ids';
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->dialog_gift->gift_related_ids = explode(',', $promotion['gift_related_ids']);
             }
             $categoryDiaStructGift = array('dialog_form' => 'dialog-form-gift', 'categoryTable' => 'categoryTable_gift');
             $this->template->content->dialog_gift->categoryDiaStruct = $categoryDiaStructGift;
             $tree = promotion::generate_tree($all_ids, 1, 0, 'gift_related_ids', $category_field, 'checkAll_gift');
             $this->template->content->dialog_gift->tree = $tree;
             //显示字段设置
             //dialog end
             break;
         case 10:
             // get_catgift_price_morethan
             $request_struct = array('where' => array(), 'orderby' => array('title_manage' => 'ASC'));
             $all_ids = CategoryService::get_instance()->index($request_struct);
             unset($all_ids['count']);
             //dialog start
             $this->template->content->dialog = new View("promotion/partial/dialog_category");
             $this->template->content->dialog->related_ids_name = 'gift_related_ids';
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->dialog->gift_related_ids = explode(',', $promotion['gift_related_ids']);
             }
             $categoryDiaStruct = array('dialog_form' => 'dialog-form', 'categoryTable' => 'categoryTable');
             $this->template->content->dialog->categoryDiaStruct = $categoryDiaStruct;
             //显示字段设置
             $category_field = array("title_manage" => "中文名称", "title" => "分类名");
             $all_ids = promotion::convert($all_ids);
             $tree = promotion::generate_tree($all_ids, 1, 0, 'gift_related_ids', $category_field, 'checkAll');
             $this->template->content->dialog->tree = $tree;
             //dialog end
             break;
     }
     // 变量绑定
     $this->template->content->faction = 'do_edit';
     $this->template->content->promotion = $promotion;
     $this->template->content->pmts_memo = $scheme['pmts_memo'];
     $this->template->content->promotion_scheme = $scheme;
 }
コード例 #4
0
ファイル: ajout.php プロジェクト: xav335/adanimalerie
<? require_once('../../classes/config.php'); ?>
<? include('../../classes/start_session_admin.php');?>
<? require_once('../../classes/classes.php'); ?>
<? include('../../include_connexion/connexion_site_on.php'); ?>
<?
	// Récupération des données passées en paramètres
	$mon_action = $_POST["mon_action"];
	$num_promotion = $_POST["num_promotion"];
	
	$promotion = new promotion();
	
	//echo "--- mon_action : " . $mon_action . "<br>";
	
	// On souhaite une modification
	if ($mon_action == "modification") {
		
		// Mise à jour de la base
		$promotion->gererDonnee( $_POST );
		header("Location: ./liste.php");
	}
	
	if ( $promotion->load( $num_promotion ) ) {
		$titre_page = "Modification d'une promotion";
		
		$titre = stripcslashes( utf8_encode( $promotion->titre ) );
		$sous_titre = stripcslashes( utf8_encode( $promotion->sous_titre ) );
		$reduction = stripcslashes( utf8_encode( $promotion->reduction ) );
		$texte = str_replace("\\", "", $promotion->texte);
		$checked_oui = ( $promotion->online == '1') ? "checked" : "";
		$checked_non = ( $promotion->online == '1') ? "" : "checked";
	}
コード例 #5
0
	function getListe( $online='' ) {
		$categorie = new promotion();
		
		$requete = "SELECT * FROM promotion";
		$requete .= " WHERE num_promotion > 0";
		if ( $online != '' ) $requete .= " AND online = '" . $online . "'";
		$requete .= " ORDER BY titre ASC";
		//echo $requete . "<br>";
		$liste = mysql_query($requete);
		
		// Retourne un tableau
		$tableau = array();
		
		if (mysql_num_rows($liste) != 0) {
			$i = 0;
			while($data = mysql_fetch_assoc($liste)) {
				
				// Tentative de chargement du commande
				if ( $categorie->load( $data["num_promotion"] ) ) {
					$tableau[$i] = new promotion();
					
					$tableau[$i]->num_promotion = $categorie->num_promotion;
					$tableau[$i]->titre = $categorie->titre;
					$tableau[$i]->sous_titre = $categorie->sous_titre;
					$tableau[$i]->reduction = $categorie->reduction;
					$tableau[$i]->texte = $categorie->texte;
					$tableau[$i]->online = $categorie->online;
					
					$i++;
				}
			}
		}
		
		return $tableau;
	}
コード例 #6
0
ファイル: content.php プロジェクト: kapai69/fl-ru-damp
    }
    ?>
                      </td>
                    </tr>
                  <?php 
}
?>
                </table>
             </div>
          </div>
          
          <!-- WORDS STAT BEGIN -->
          <br/>
          <a href="javascript:void(0)" onclick="$('ov-pst').toggleClass('b-shadow_hide');" class="blue">Статистика переходов по ключевым словам</a>
          <?php 
$aWordsStat = promotion::getWordsSummary($uid);
?>
<script type="text/javascript">
function toggleTypeStatKeyword(type) {
    if(type == 1) {
        $$('.stat-link-disabled').removeClass('global_hide'); 
        $('l2').set('html', 'Все ключевые слова');
        $('l1').set('html', '<a href="javascript:void(0);" onclick="toggleTypeStatKeyword(0)">Только активные</a>');
    } else {
        $$('.stat-link-disabled').addClass('global_hide'); 
        $('l1').set('html', 'Только активные');
        $('l2').set('html', '<a href="javascript:void(0);" onclick="toggleTypeStatKeyword(1)">Все ключевые слова</a>');
    }
}
</script> 
コード例 #7
0
ファイル: rating.server.php プロジェクト: kapai69/fl-ru-damp
function GetRating($type, $login = null, $width = null)
{
    session_start();
    $objResponse = new xajaxResponse();
    $login = change_q_x($login, TRUE);
    $user = new users();
    $user->GetUser($login);
    $uid = $user->uid;
    if (!$uid) {
        $uid = get_uid(false);
    }
    if (!$uid) {
        $objResponse->script('this.document.location.reload();');
        return $objResponse;
    }
    $user->GetUserByUID($uid);
    $rating = new rating();
    switch ($type) {
        case 'year':
            $TIME = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
            $pro_periods_date = date('Y-01-01', $TIME);
            $res = $rating->getRatingByYear($uid, date('Y', $TIME));
            $periods = rating::getMonthParts(date('Y-01-01'));
            $data = array();
            if ($res) {
                foreach ($periods as $m => $mm) {
                    if ($m < date('m')) {
                        foreach ($mm as $d) {
                            if ($d > time() || $d < strtotime($user->reg_date)) {
                                continue;
                            }
                            $data[$m][date('Y-m-d', $d)] = null;
                            if ($d >= strtotime($user->reg_date)) {
                                $data[$m][date('Y-m-d', $d)] = 0;
                            }
                        }
                    }
                }
            }
            $start_r = null;
            if ($res) {
                if (date('Y', strtotime($res[0]['_date'])) == date('Y') - 1) {
                    $start_r = $res[0]['rating'];
                    if (isset($res[1]) && strtotime($res[1]['_date']) != $periods[0][0]) {
                        $res[0]['_date'] = date('Y-m-d', $periods[0][0]);
                    } else {
                        $res = array_slice($res, 1);
                    }
                }
            } else {
                $res = array();
            }
            $verify_factor = 0;
            $verify_date = rating::GetVerifyDate($uid);
            foreach ($res as $row) {
                $t = strtotime($row['_date']);
                $m = (int) date('m', $t);
                $verify_factor = 0;
                if ($row['is_verify'] == 't') {
                    if ($verify_date) {
                        if (strtotime($verify_date) < $t) {
                            $verify_factor = 0.2;
                        }
                    } else {
                        $verify_factor = 0.2;
                    }
                }
                $data[$m - 1][date('Y-m-d', $t)] = array('rating' => floatval($row['rating']), 'verify' => floatval($row['rating'] * $verify_factor), 'pro' => 0);
            }
            $lastval = null;
            foreach ($data as $i => $mon) {
                foreach ($mon as $d => $prt) {
                    $vl = !$prt ? $lastval : $prt;
                    $data[$i][$d] = $vl;
                    //                    if($prt !== null)
                    $lastval = $vl;
                }
            }
            $pro_periods = promotion::GetUserProPeriods($uid, $pro_periods_date, TRUE);
            if ($pro_periods) {
                $pro = array();
                foreach ($pro_periods as $p => $period) {
                    if (date('Y', strtotime($period['from_time'])) > date('Y', $TIME) && date('Y', strtotime($period['to_time']) > date('Y', $TIME))) {
                        continue;
                    }
                    $d1 = (int) date('z', strtotime($period['from_time']));
                    $d2 = (int) date('z', strtotime($period['to_time']));
                    if (date('Y', strtotime($period['from_time'])) < date('Y', $TIME)) {
                        $d1 = 0;
                    }
                    if (date('Y', strtotime($period['to_time'])) > date('Y', $TIME)) {
                        $d2 = (int) date('z', mktime(0, 0, 0, 12, 31, date('Y')));
                    }
                    $_factor = 0.2;
                    if ($period['is_profi'] == 1) {
                        $_factor = 0.4;
                    }
                    foreach ($data as $mon => $val) {
                        foreach ($val as $per => $r) {
                            $day = (int) date('z', strtotime($per));
                            if ($d1 < $day && $d2 >= $day) {
                                $data[$mon][$per]['pro'] = floatval($data[$mon][$per]['rating'] * $_factor);
                            }
                        }
                    }
                    $pro[$p] = $d1 != $d2 ? array($d1, $d2) : array($d1);
                }
                $config['pro'] = $pro;
            }
            $new_data = array();
            if ($data) {
                foreach ($data as $mon => $val) {
                    foreach ($val as $per => $r) {
                        $new_data[$mon][$per] = $r['rating'] + $r['verify'] + $r['pro'];
                    }
                }
            }
            $config['data'] = $new_data;
            $config['cur'] = intval(date('m', $TIME));
            $config['days'] = date('z', mktime(0, 0, 0, 12, 31, date('Y'))) + 1;
            $config['regdate'] = $user->reg_date;
            break;
        case 'prev':
        default:
            $config = array();
            $data = array();
            $config['hilight'] = array();
            if ($type == 'prev') {
                $TIME = mktime(0, 0, 0, date('m') - 1, 1, date('Y'));
                $res = $rating->getRatingByMonth($uid, date('Y-m-d', $TIME));
                if (!$res) {
                    $res = array();
                }
                $graphstart = strtotime($user->reg_date);
                if (count($res) && date('Ym', strtotime($res[0]['_date'])) == date('Ym', $TIME)) {
                    $graphstart = strtotime($res[0]['_date']);
                } else {
                    if (!count($res)) {
                        $graphstart = time();
                    }
                }
                $rating_data = array();
                $verify_date = null;
                $verify_factor = 0;
                $n = 0;
                foreach ($res as $d) {
                    if (date('Y-m', strtotime($d['_date'])) != date('Y-m', $TIME)) {
                        continue;
                    }
                    //$rating_data[intval(date('d', strtotime($d['_date'])))] = $d['rating'];
                    $verify_factor = 0;
                    if ($verify_date === null) {
                        $verify_date = rating::GetVerifyDate($d['user_id']);
                    }
                    if ($d['is_verify'] == 't') {
                        if ($verify_date) {
                            if (strtotime($verify_date) < strtotime($d['_date'])) {
                                $verify_factor = 0.2;
                            }
                        } else {
                            $verify_factor = 0.2;
                        }
                    }
                    if ($n == 0) {
                        $res[0]['verify_factor'] = $verify_factor;
                    }
                    $rating_data[intval(date('d', strtotime($d['_date'])))] = array('rating' => floatval($d['rating']), 'verify' => floatval($d['rating'] * $verify_factor), 'pro' => 0);
                    ++$n;
                }
                $last = null;
                for ($i = 0; $i < date('t', $TIME); ++$i) {
                    if (strtotime(date('Y-m-' . ($i + 1), $TIME)) < $graphstart) {
                        $last = null;
                    } else {
                        $last = $last !== null ? $last : 0;
                        if ($i == 0 && !isset($rating_data[$i + 1])) {
                            $last = array('rating' => floatval($res[0]['rating']), 'verify' => floatval($res[0]['rating'] * $res[0]['verify_factor']), 'pro' => 0);
                        }
                    }
                    if (isset($rating_data[$i + 1])) {
                        $last = $rating_data[$i + 1];
                    }
                    $data[$i] = $last;
                }
            } else {
                $TIME = mktime(0, 0, 0, date('m'), date('d'), date('Y'));
                $res = $rating->getRatingByMonth($uid, date('Y-m-d', $TIME));
                if (!$res) {
                    $res = array();
                }
                $graphstart = strtotime($user->reg_date);
                if (count($res) && date('Ym', strtotime($res[0]['_date'])) == date('Ym', $TIME)) {
                    $graphstart = strtotime($res[0]['_date']);
                }
                $rating_data = array();
                $verify_date = null;
                $verify_factor = 0;
                $n = 0;
                foreach ($res as $d) {
                    if (date('Y-m', strtotime($d['_date'])) != date('Y-m', $TIME)) {
                        continue;
                    }
                    $verify_factor = 0;
                    if ($verify_date === null) {
                        $verify_date = rating::GetVerifyDate($d['user_id']);
                    }
                    if ($d['is_verify'] == 't') {
                        if ($verify_date) {
                            if (strtotime($verify_date) < strtotime($d['_date'])) {
                                $verify_factor = 0.2;
                            }
                        } else {
                            $verify_factor = 0.2;
                        }
                    }
                    if ($n == 0) {
                        $res[0]['verify_factor'] = $verify_factor;
                    }
                    $rating_data[intval(date('d', strtotime($d['_date'])))] = array('rating' => floatval($d['rating']), 'verify' => floatval($d['rating'] * $verify_factor), 'pro' => 0);
                    ++$n;
                }
                $config['cur'] = intval(date('d', $TIME));
                $last = 0;
                for ($i = 0; $i < date('d', $TIME); ++$i) {
                    if (strtotime(date('Y-m-' . ($i + 1), $TIME)) < $graphstart) {
                        $last = null;
                    } else {
                        $last = $last !== null ? $last : 0;
                        if ($i == 0 && !isset($rating_data[$i + 1])) {
                            $last = array('rating' => floatval($res[0]['rating']), 'verify' => floatval($res[0]['rating'] * $res[0]['verify_factor']), 'pro' => 0);
                        }
                    }
                    if (isset($rating_data[$i + 1])) {
                        $last = $rating_data[$i + 1];
                    }
                    $data[$i] = $last;
                }
            }
            $pro_periods_date = date('Y-01-01', $TIME);
            for ($i = 1; $i <= date('t', $TIME); ++$i) {
                $t = mktime(0, 0, 0, date('m', $TIME), $i, date('Y', $TIME));
                if (date('w', $t) == 0 || date('w', $t) == 6) {
                    $config['hilight'][] = $i;
                }
            }
            $pro_periods = promotion::GetUserProPeriods($uid, $pro_periods_date, TRUE);
            if ($pro_periods) {
                $pro = array();
                $tmp = array();
                foreach ($pro_periods as $p => $period) {
                    if (date('Ym', strtotime($period['from_time'])) > date('Ym', $TIME)) {
                        continue;
                    }
                    if (date('Ym', strtotime($period['to_time'])) < date('Ym', $TIME)) {
                        continue;
                    }
                    $d1 = (int) date('d', strtotime($period['from_time']));
                    $d2 = (int) date('d', strtotime($period['to_time']));
                    if (date('Ym', strtotime($period['from_time'])) < date('Ym', $TIME)) {
                        $d1 = 1;
                    }
                    if (date('Ym', strtotime($period['to_time'])) > date('Ym', $TIME)) {
                        $d2 = (int) date('t', $TIME);
                    }
                    $_factor = 0.2;
                    //PRO ONLY
                    if ($period['is_profi'] == 1) {
                        $_factor = 0.4;
                        //PROFI
                    }
                    foreach ($data as $day => $val) {
                        if (isset($tmp[$day]) || $val === null) {
                            continue;
                        }
                        if ($d1 <= $day + 1 && $d2 >= $day + 1) {
                            $data[$day]['pro'] = floatval($data[$day]['rating'] * $_factor);
                            //rating::PRO_FACTOR;
                            $tmp[$day] = 1;
                        }
                    }
                    $pro[$p] = $d1 != $d2 ? array($d1, $d2) : array($d1);
                }
                $config['pro'] = $pro;
            }
            if (strtotime($user->reg_date) > strtotime($pro_periods_date)) {
                $config['regdate'] = date('Y-m-d', strtotime($user->reg_date));
            }
            $new_data = array();
            if ($data) {
                foreach ($data as $day => $value) {
                    $new_data[$day] = $value['rating'] + $value['verify'] + $value['pro'];
                }
            }
            // сегодняшний рейтинг берем из $user - тут он актуальный и не зависит от кэша
            if ($type === 'month') {
                array_pop($new_data);
                $new_data[] = floatval($user->rating);
            }
            $config['data'] = $new_data;
            $config['days'] = date('t', $TIME);
            $config['startdate'] = date('Y-m-01', $TIME);
    }
    if ($width) {
        $config['w'] = (int) $width;
    }
    $config = json_encode($config);
    $objResponse->script("loadGraph('{$type}', {$config});");
    return $objResponse;
}
コード例 #8
0
ファイル: svg.php プロジェクト: Nikitian/fl-ru-damp
//        header('Content-type: image/svg+xml');
//    echo $svg;
//    exit();
$overwrite = true;
if (!$cfile->id || $overwrite) {
    if ($cfile->id) {
        $cfile->Delete($cfile->id);
    }
    $file2 = "/users/" . substr($u_login, 0, 2) . "/{$u_login}/upload/{$file_name}." . ($file_ext == 'svg' ? 'html' : 'svg');
    $cf2 = new CFile($file2);
    if ($cf2->id) {
        $cf2->Delete($cf2->id);
    }
    $data = $rating->{$get_rating_by}($uid, $get_rating_date);
    $graph = new $graph_class($TIME, $data);
    $graph->setPro(promotion::GetUserProPeriods($uid, $pro_periods_date));
    //    $graph->setPro(array(
    //        array(
    //            'from_time' => '2010-01-03',
    //            'to_time' => '2010-06-15'
    //        ),
    //        array(
    //            'from_time' => '2010-12-02',
    //            'to_time' => '2010-12-28'
    //        )
    //    ));
    $svg = $graph->render();
    $cfile = new CFile();
    $cfile->name = "{$file_name}.{$file_ext}";
    $cfile->path = "/users/" . substr($u_login, 0, 2) . "/{$u_login}/upload/";
    $cfile->modified = '';
コード例 #9
0
ファイル: promotion.php プロジェクト: Nikitian/fl-ru-damp
 /**
  * Возвращает периоды в которых пользователь был PRO
  * @param   integer  $user_id     uid пользователя
  * @param   string   $from_date   начало периода в формате postgresql
  * @param   boolean  $check_freeze   учитывать периоды заморозки
  * @return  array                 массив с данными или NULL если данных нет или произошла ошибка
  */
 function GetUserProPeriods($user_id, $from_date, $check_freeze = false)
 {
     global $DB;
     $sql = "SELECT DISTINCT\n            CASE WHEN from_date < ? THEN ? ELSE from_date END  as from_time,\n            from_date + to_date + COALESCE(freeze_to, '0')::interval as to_time,\n            CASE WHEN tarif IN(164) THEN 1 ELSE 0 END as is_profi\n       FROM orders\n      WHERE from_id = ?i \n        -- AND payed = true -- deprecated #0021704\n        AND from_date + to_date + COALESCE(freeze_to, '0')::interval >= ? \n      ORDER BY from_time, to_time DESC";
     $res = $DB->rows($sql, $from_date, $from_date, $user_id, $from_date);
     if ($DB->error || !count($res)) {
         return null;
     }
     if ($check_freeze) {
         $freeze = promotion::getFreezePeriods($user_id);
         if (!$freeze) {
             $freeze = array();
         }
         $f = array();
         $pro = array();
         foreach ($freeze as $i => $p) {
             $from = strtotime(date('Ymd', strtotime($p['from_time'])));
             $to = strtotime(date('Ymd', strtotime($p['to_time'])));
             $d = $from;
             while ($d < $to) {
                 $f[] = $d;
                 $d = mktime(0, 0, 0, date('m', $d), date('d', $d) + 1, date('Y', $d));
             }
         }
         $st = 1000;
         foreach ($res as $i => $p) {
             $from = strtotime(date('Ymd', strtotime($p['from_time'])));
             $to = strtotime(date('Ymd', strtotime($p['to_time'])));
             $d = $from;
             $freezed = false;
             $pro[$st]['is_profi'] = $p['is_profi'];
             while ($d <= $to) {
                 if (!in_array($d, $f)) {
                     $pro[$st][] = $d;
                     $freezed = false;
                 } else {
                     if (!$freezed) {
                         $st++;
                     }
                     $freezed = true;
                 }
                 $d = mktime(0, 0, 0, date('m', $d), date('d', $d) + 1, date('Y', $d));
             }
             $st++;
         }
         $new = array();
         foreach ($pro as $k => $v) {
             $new[$k]['from_time'] = date('Y-m-d', $v[0]);
             $new[$k]['to_time'] = date('Y-m-d', end($v));
             $new[$k]['is_profi'] = $v['is_profi'];
         }
         //        echo '<pre>'; var_dump($new); die();
         if (count($new)) {
             $res = $new;
         }
     }
     return count($res) ? $res : null;
 }
コード例 #10
0
ファイル: guests.php プロジェクト: Nikitian/fl-ru-damp
">Из поиска</a></li>
							<li <?php 
echo $fromType == 'others' ? 'class="active"' : '';
?>
><a href="/promotion/?bm=1&from=others<?php 
echo $login ? "&user={$login}" : '';
?>
">Другое</a></li>
					</ul>
			</div>
  </div>
      <div class="promotion">
        <?php 
if ($user->is_pro == 't' || $iAmAdmin) {
    $t_guests = promotion::GetGuests($uid, $TODAY, $TOMORROW, $fromType);
    $y_guests = promotion::GetGuests($uid, $YESTERDAY, $TODAY, $fromType);
    ?>
      
          <div style="margin:40px 0 0 0">
            <div class="tbl-users">
               <?php 
    echo t_promotion::guests($t_guests, $HOUR - 1, 'Сегодня');
    ?>
            </div>
            <br /><br /><br /><br /><br /><br /><br /><br />
            <div class="tbl-users">
               <?php 
    echo t_promotion::guests($y_guests, 23, 'Вчера');
    ?>
            </div>
          </div>
コード例 #11
0
ファイル: liste.php プロジェクト: xav335/adanimalerie
<? require_once('../../classes/config.php'); ?>
<? include('../../classes/start_session_admin.php');?>
<? require_once('../../classes/classes.php'); ?>
<? include('../../include_connexion/connexion_site_on.php'); ?>
<?
	// Récupération des données passées en paramètres
	$mon_action = $_POST["mon_action"];
	$num_promotion = $_POST["num_promotion"];
	
	$ordre = $_POST["ordre"];
	$mouvement = $_POST["mouvement"];
	$id_changement = $_POST["id_changement"];
	
	$promotion = new promotion();
	
	// Suppression d'un cours
	if ($mon_action == "suppression") {
		//echo "Suppression...<br>";
		if ( $promotion->load( $num_promotion ) ) $promotion->supprimer();
	}
	
	// Liste des promotions disponibles
	$liste_promotion = $promotion->getListe();
	
	$menu = "promotion";
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<head>
	
	<!-- Titre de la page et CSS -->
コード例 #12
0
ファイル: cpn_promotion.php プロジェクト: RenzcPHP/3dproduct
 public function edit()
 {
     role::check('promotion_coupon');
     // 收集请求数据
     $request_data = $this->input->get();
     $promotion = Mycpn_promotion::instance($request_data['id'])->get();
     $cpns_id = $promotion['cpns_id'];
     if (!$cpns_id) {
         remind::set(Kohana::lang('o_global.access_denied'), request::referrer(), 'error');
     }
     $promotion['money_from'] = sprintf('%.3f', $promotion['money_from']);
     $promotion['money_to'] = sprintf('%.3f', $promotion['money_to']);
     $coupon_schemes = Mycoupon_scheme::instance($cpns_id)->get();
     //实例化session
     $session = Session::instance();
     $this->template->content = new View("promotion/edit_cpn_promotion_" . $cpns_id);
     // extra process needed for IDs
     switch ($cpns_id) {
         case 3:
             // discount_cart_user_buy
             $all_ids = array();
             if (isset($promotion['related_ids'])) {
                 $query_struct = array('where' => array('id' => explode(',', $promotion['related_ids'])));
                 $all_ids = Myuser::instance()->lists($query_struct);
             }
             $this->template->content->users_area = new View("promotion/partial/edit_users");
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->users_area->related_ids = explode(',', $promotion['related_ids']);
             }
             $this->template->content->users_area->thing = 'users';
             $this->template->content->thing = 'users';
             $this->template->content->users_area->all_ids = $all_ids;
             $this->template->content->users_area->relatedUsers = "relatedUsers";
             $this->template->content->users_area->related_idsu = "related_ids";
             $this->template->content->users_area->addUser = "******";
             //$this->template->content->all_ids = $all_ids;
             //dialog start
             $this->template->content->dialog = new View("promotion/partial/dialog_user");
             $userDiaStruct = array('dialog_form' => 'dialog-form-user', 'userSearchType' => 'userSearchType', 'userKeyword' => 'userKeyword', 'userSearchbtn' => 'userSearchbtn', 'userTable' => 'userTable', 'checkAll' => 'checkAll', 'users' => 'users');
             $this->template->content->dialog->userDiaStruct = $userDiaStruct;
             //$this->template->content->dialog->all_ids = $all_ids;
             //显示字段设置
             $js_user_field = 'var user_field = {"用户登录邮箱":"email"};';
             $user_field = array('email' => "用户登录邮箱");
             $this->template->content->js_user_field = $js_user_field;
             $this->template->content->users_area->user_field = $user_field;
             //dialog end
             break;
         case 4:
             // discount_cart_buy_product
             if ($session->get('sessionErrorData') === false) {
                 //                $this->template->content->products_area->related_ids = explode(',', $promotion['related_ids']);
                 $related_ids = explode(',', $promotion['related_ids']);
             } else {
                 $related_ids = $session->get('sessionErrorData');
                 $related_ids = $related_ids['related_ids'];
             }
             $request_struct = array('where' => array('on_sale' => 1, 'id' => $related_ids), 'orderby' => array('name_manage' => 'ASC'));
             $all_ids = ProductService::get_instance()->index($request_struct);
             $this->add_category_name($all_ids);
             $this->template->content->products_area = new View("promotion/partial/edit_products");
             $this->template->content->products_area->all_ids = $all_ids;
             $this->template->content->products_area->thing = 'products';
             $this->template->content->thing = 'products';
             //dialog start
             $this->template->content->dialog = new View("promotion/partial/dialog_product");
             $productDiaStruct = array('dialog_form' => 'dialog-form-product', 'productSearchType' => 'productSearchType', 'productKeyword' => 'productKeyword', 'productSearchbtn' => 'productSearchbtn', 'productTable' => 'productTable', 'checkAll' => 'checkAll', 'products' => 'products');
             $this->template->content->dialog->productDiaStruct = $productDiaStruct;
             //显示字段设置
             $js_product_field = 'var product_field = {\'SKU\':"sku","中文名称":"name_manage","商品名称":"title","分类名称":"category_name"};';
             $product_field = array('sku' => 'SKU', "name_manage" => "中文名称", "title" => "商品名称", "category_name" => "分类名称");
             $this->template->content->js_product_field = $js_product_field;
             $this->template->content->products_area->product_field = $product_field;
             //dialog end
             break;
         case 5:
             // discount_category
             $request_struct = array('where' => array(), 'orderby' => array('title_manage' => 'ASC'));
             $all_ids = CategoryService::get_instance()->index($request_struct);
             $all_ids = promotion::convert($all_ids);
             //dialog start
             $related_ids = 'related_ids';
             $this->template->content->dialog = new View("promotion/partial/dialog_category");
             $this->template->content->dialog->related_ids_name = $related_ids;
             if ($session->get('sessionErrorData') === false) {
                 $this->template->content->dialog->related_ids = explode(',', $promotion['related_ids']);
             }
             $categoryDiaStruct = array('dialog_form' => 'dialog-form', 'categoryTable' => 'categoryTable');
             $this->template->content->dialog->categoryDiaStruct = $categoryDiaStruct;
             $this->template->content->dialog->all_ids = $all_ids;
             //显示字段设置
             $category_field = array("title_manage" => "中文名称", "title" => "分类名");
             $tree = promotion::generate_tree($all_ids, 1, 0, $related_ids, $category_field, 'checkAll');
             $this->template->content->dialog->tree = $tree;
             //dialog end
             break;
     }
     // 变量绑定
     $this->template->content->promotion = $promotion;
     $this->template->content->coupon_schemes = $coupon_schemes;
     $this->template->content->coupon = Mycoupon::instance($promotion['cpn_id'])->get();
 }