Beispiel #1
0
 public function actionSingle($id)
 {
     $brand = Brands::model()->findByPk($id);
     $sales = Sales::model()->findAll(array('condition' => 'status=1 and brand_id=:brandId and ((start=finish and start<=:now) OR :now between start and finish)', 'params' => array(':brandId' => $brand->id, ':now' => date('Y-m-d H:i:s'))));
     $data = array('brand' => $brand, 'sales' => $sales, 'title' => $brand->name);
     $this->render('single', $data);
 }
Beispiel #2
0
 public function actionDefault()
 {
     $main_rubric = Rubrics::model()->find(array('condition' => 'main=1'));
     $order = 'start desc, id desc';
     $sales = Sales::model()->findAll(array('condition' => 'start<=:now and finish>=:now and (sale>0 or action=1) and status=1', 'params' => array(':now' => date('Y-m-d')), 'order' => $order));
     $new = Sales::model()->findAll(array('condition' => 'start<=:now and finish>=:now and new=1 and status=1', 'params' => array(':now' => date('Y-m-d')), 'order' => 'finish'));
     $data = array('sales' => $sales, 'new' => $new, 'rubric' => $main_rubric, 'title' => $main_rubric->title ? $main_rubric->title : $main_rubric->name, 'keywords' => $main_rubric->keywords, 'description' => $main_rubric->description, 'metaImage' => 'http://' . $_SERVER['HTTP_HOST'] . '/static/img/logo_big.png');
     $this->render('main', $data);
 }
Beispiel #3
0
 public function actionSingle($id)
 {
     $single = Sales::model()->findByPk($id);
     if (!$single) {
         $this->render('/errors/404');
     }
     $rubric = Rubrics::model()->findByPk($single->rubric_id);
     $data = array('rubric' => $rubric, 'data' => $single, 'title' => $single->name, 'keywords' => str_replace(' ', ',', $single->announce), 'description' => $single->announce, 'metaImage' => 'http://' . $_SERVER['HTTP_HOST'] . $this->getImageUrl($single, 'b'));
     $this->render('single', $data);
 }
 public function actionWhatsNew()
 {
     if (!Yii::app()->user->isGuest) {
         $user = User::model()->findByPk(Yii::app()->user->getId());
         $lastLogin = $user->lastLogin;
         $contacts = Contacts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $actions = Actions::model()->findAll("lastUpdated > {$lastLogin} AND (assignedTo='" . Yii::app()->user->getName() . "' OR assignedTo='Anyone') ORDER BY lastUpdated DESC LIMIT 50");
         $sales = Sales::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $accounts = Accounts::model()->findAll("lastUpdated > {$lastLogin} ORDER BY lastUpdated DESC LIMIT 50");
         $arr = array_merge($contacts, $actions, $sales, $accounts);
         $records = Record::convert($arr);
         $dataProvider = new CArrayDataProvider($records, array('id' => 'id', 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage()), 'sort' => array('attributes' => array('lastUpdated', 'name'))));
         $this->render('whatsNew', array('records' => $records, 'dataProvider' => $dataProvider));
     } else {
         $this->redirect('login');
     }
 }
 /**
  * Returns the data model based on the primary key given in the GET variable.
  * If the data model is not found, an HTTP exception will be raised.
  * @param integer the ID of the model to be loaded
  */
 public function loadModel($id)
 {
     $model = Sales::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, Yii::t('app', 'The requested page does not exist.'));
     }
     return $model;
 }
Beispiel #6
0
 public function getCountRubricSales($rubric_id)
 {
     $cnt = Sales::model()->count(array('condition' => 'status=1 and rubric_id=:rubricId', 'params' => array(':rubricId' => $rubric_id)));
     return $cnt;
 }
 public function actionGetStageMembers($workflowId, $stage)
 {
     // $contactIds = Yii::app()->db->createCommand()->select('contactId')->from('x2_list_items')->where('x2_list_items.listId='.$id)->queryColumn();
     // die(var_dump($contactIds));
     // $search = CActiveRecord::model('ContactChild')->findAllByPk($contactIds);
     // return $search;
     if (!is_numeric($workflowId) || !is_numeric($stage)) {
         return new CActiveDataProvider();
     }
     $actionDescription = $workflowId . ':' . $stage;
     $contactsSql = Yii::app()->db->createCommand()->select('x2_contacts.*')->from('x2_contacts')->join('x2_actions', 'x2_contacts.id = x2_actions.associationId')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='contacts' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0) AND (x2_contacts.visibility=1 OR x2_contacts.assignedTo='" . Yii::app()->user->getName() . "')")->getText();
     $contactsCount = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='contacts' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->queryScalar();
     $contactsDataProvider = new CSqlDataProvider($contactsSql, array('totalItemCount' => $contactsCount, 'sort' => array('attributes' => array('firstName', 'lastName', 'phone', 'phone2', 'createDate', 'lastUpdated', 'leadSource'), 'defaultOrder' => 'lastUpdated DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
     $salesSql = Yii::app()->db->createCommand()->select('x2_sales.*')->from('x2_sales')->join('x2_actions', 'x2_sales.id = x2_actions.associationId')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='sales' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->getText();
     $salesCount = Yii::app()->db->createCommand()->select('COUNT(*)')->from('x2_actions')->where("x2_actions.workflowId={$workflowId} AND x2_actions.stageNumber={$stage} AND x2_actions.associationType='sales' AND complete!='Yes' AND (completeDate IS NULL OR completeDate=0)")->queryScalar();
     $salesDataProvider = new CSqlDataProvider($salesSql, array('totalItemCount' => $salesCount, 'sort' => array('attributes' => array('firstName', 'lastName', 'phone', 'phone2', 'createDate', 'lastUpdated', 'leadSource'), 'defaultOrder' => 'lastUpdated DESC'), 'pagination' => array('pageSize' => ProfileChild::getResultsPerPage())));
     if (!empty($contactsDataProvider)) {
         $this->widget('zii.widgets.grid.CGridView', array('id' => 'contacts-grid', 'baseScriptUrl' => Yii::app()->theme->getBaseUrl() . '/css/gridview', 'template' => '<h2>' . Yii::t('contacts', 'Contacts') . '</h2><div class="title-bar">' . '{summary}</div>{items}{pager}', 'dataProvider' => $contactsDataProvider, 'enableSorting' => false, 'columns' => array(array('name' => 'lastName', 'header' => Yii::t('contacts', 'Name'), 'value' => 'CHtml::link($data["firstName"]." ".$data["lastName"],array("/contacts/default/view","id"=>$data["id"]))', 'type' => 'raw', 'htmlOptions' => array('width' => '30%')), array('name' => 'phone', 'header' => Yii::t('contacts', 'Work Phone')), array('name' => 'createDate', 'header' => Yii::t('contacts', 'Create Date'), 'value' => 'date("Y-m-d",$data["createDate"])', 'type' => 'raw', 'htmlOptions' => array('width' => '15%')), array('name' => 'lastUpdated', 'header' => Yii::t('contacts', 'Last Updated'), 'value' => 'date("Y-m-d",$data["lastUpdated"])', 'type' => 'raw', 'htmlOptions' => array('width' => '15%')), array('name' => 'leadSource', 'header' => Yii::t('contacts', 'Lead Source')))));
     }
     if (!empty($salesDataProvider)) {
         $this->widget('zii.widgets.grid.CGridView', array('id' => 'contacts-grid', 'baseScriptUrl' => Yii::app()->theme->getBaseUrl() . '/css/gridview', 'template' => '<h2>' . Yii::t('sales', 'Sales') . '</h2><div class="title-bar">' . '{summary}</div>{items}{pager}', 'dataProvider' => $salesDataProvider, 'columns' => array(array('header' => Sales::model()->getAttributeLabel('name'), 'name' => 'name', 'value' => 'CHtml::link($data["name"],array("/sales/default/view","id"=>$data["id"]))', 'type' => 'raw', 'htmlOptions' => array('width' => '40%')), array('header' => Sales::model()->getAttributeLabel('quoteAmount'), 'name' => 'quoteAmount', 'value' => 'Yii::app()->locale->numberFormatter->formatCurrency($data["quoteAmount"],Yii::app()->params->currency)', 'type' => 'raw'), array('header' => Sales::model()->getAttributeLabel('salesStage'), 'name' => 'salesStage', 'value' => 'Yii::t("sales",$data["salesStage"])', 'type' => 'raw'), array('header' => Sales::model()->getAttributeLabel('expectedCloseDate'), 'name' => 'expectedCloseDate', 'value' => 'empty($data->expectedCloseDate)?"":date("Y-m-d",$data["expectedCloseDate"])', 'type' => 'raw', 'htmlOptions' => array('width' => '13%')), array('header' => Sales::model()->getAttributeLabel('assignedTo'), 'name' => 'assignedTo', 'value' => 'empty($data["assignedTo"])?Yii::t("app","Anyone"):$data["assignedTo"]', 'type' => 'raw'))));
     }
 }
 public function actionAddSales()
 {
     $pid = $_POST['pid'];
     $saleDate = $_POST['saleDate'];
     $saleCount = $_POST['saleCount'];
     // $pid = 9;
     // $saleDate = '2012-03-10';
     // $saleCount = 7;
     $sql = "SELECT * FROM product WHERE id=" . $pid;
     $product = Product::model()->findBySql($sql);
     $result = false;
     if ($product) {
         // $sql = "SELECT * FROM sales WHERE pid=".$pid." AND timestamp=".$saleDate;
         $sql = "SELECT * FROM sales WHERE pid=" . $pid . " AND timestamp='" . $saleDate . "'";
         $haveSale = Sales::model()->findBySql($sql);
         // echo var_dump($haveSale);
         // die();
         if (null == $haveSale) {
             // echo "yes";
             $newSale = new Sales();
             $newSale->pid = $pid;
             $newSale->count = $saleCount;
             $newSale->timestamp = $saleDate;
             $newSale->save();
             $result = true;
         }
     }
     echo $result;
 }
Beispiel #9
0
 public static function getNames()
 {
     $arr = Sales::model()->findAll();
     $names = array(0 => "None");
     foreach ($arr as $sale) {
         $names[$sale->id] = $sale->name;
     }
     return $names;
 }
Beispiel #10
0
<?php

$crumbs = Yii::app()->params['crumbs'];
$vert = Rubrics::model()->getMenu('vert');
if ($vert) {
    ?>
	<div id="vert_menu">		<h3>Категории:</h3>		<?php 
    foreach ($vert as $k => $v) {
        ?>
			<div>				<a href="<?php 
        echo $v->getLink();
        ?>
" class="<?php 
        if ($crumbs[0]->id == $v->id) {
            ?>
active<?php 
        }
        ?>
">					<?php 
        echo $v->name;
        ?>
					<!--sup>(<?php 
        echo Sales::model()->getCountRubricSales($v->id);
        ?>
)</sup-->				</a>			</div>		<?php 
    }
    ?>
	</div><?php 
}