Exemplo n.º 1
0
 public function checkUserLevel()
 {
     try {
         if (Auth::user()) {
             $usersinfo = Auth::user();
             $getIndicatorDescription = Indicator::where('id', '=', $usersinfo->indicator_id)->where('indicator_for', '=', 'STORE')->get();
             if (count($getIndicatorDescription) <= 0) {
                 return 'empty';
             } else {
                 // foreach($getIndicatorDescription as $indicatorInfo)
                 // {
                 // $indicator_id=$indicatorInfo->id;
                 // $indicator_name=$indicatorInfo->indicator_name;
                 // $indicator_for=$indicatorInfo->indicator_for;
                 // //id-indicator name - indicator for
                 // return $indicator_id.'-'.$indicator_name.'-'.$indicator_for;
                 // }
                 return $getIndicatorDescription;
             }
         } else {
             return 'authFailed';
         }
     } catch (\Exception $e) {
         return 'authErr';
     }
 }
 public function triggerNotification($frequency)
 {
     $indicators = Indicator::model()->findAll();
     foreach ($indicators as $indicator) {
         if ($indicator->indicatorFrequency) {
             if ($indicator->indicatorFrequency[0]->code == $frequency) {
                 echo 'found one: ' . 'indicator ID: ' . $indicator->indicatorFrequency[0]->code . "\r\n";
                 foreach ($indicator->indicatorFramework as $framework) {
                     $mapper = EamsFrameworkIndicatorMapping::model()->find('indicator_id=:i AND framework_id=:f', array(':i' => $indicator->id, ':f' => $framework->id));
                     //Initialize facts table: indicator value to be filled after notification has been sent
                     $fact = new EamsFacts();
                     $fact->framework_ind_id = $mapper->id;
                     $fact->time_id = TimeDimension::getTimeIdByDate(date('dmy'));
                     echo '<pre>';
                     print_r($fact);
                     print_r($mapper);
                     echo "\r\n";
                     if ($fact->save()) {
                         echo "Saved\r\n";
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 3
0
 public function getValues()
 {
     parent::getValues();
     $query = $this->db->newStatement("\n            SELECT COUNT(category_id) cnt, user_id, DATE_FORMAT(date_creation,'%Y-%m') date FROM log_article\n            WHERE DATE_FORMAT(date_creation,'%Y-%m')>=:f: AND DATE_FORMAT(date_creation,'%Y-%m')<=:t: AND user_id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":) AND type=0\n            GROUP BY user_id, DATE_FORMAT(date_creation,'%Y-%m')\n        ");
     $query->setVarChar('f', $this->start);
     $query->setVarChar('t', $this->end);
     foreach ($this->users as $key => $curr) {
         $query->setInteger('uid' . $key, $curr);
     }
     return $this->processResult($query->getAllRecords());
 }
 public function getValues()
 {
     parent::getValues();
     $query = $this->conn->newStatement("\n            SELECT SUM(t.daily) cnt, employee_id user_id, DATE_FORMAT(date,'%Y-%m')  date FROM (\n                SELECT ROUND(IF(SUM(TIME_TO_SEC(finish)-TIME_TO_SEC(start))>4,14400,SUM(TIME_TO_SEC(finish)-TIME_TO_SEC(start)))/3600) daily, employee_id, DATE_FORMAT(start,'%Y-%m-%d') date \n                FROM timesheet \n                WHERE DATE_FORMAT(start,'%Y-%m')>=:f: AND DATE_FORMAT(start,'%Y-%m')<=:t: AND employee_id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":) AND DATE_FORMAT(start,'%Y-%m-%d')=DATE_FORMAT(finish,'%Y-%m-%d')\n                GROUP BY employee_id, DATE_FORMAT(start,'%Y-%m-%d')\n            ) t\n            GROUP BY employee_id, DATE_FORMAT(date,'%Y-%m') \n        ");
     $query->setVarChar('f', $this->start);
     $query->setVarChar('t', $this->end);
     foreach ($this->users as $key => $curr) {
         $query->setInteger('uid' . $key, $curr);
     }
     return $this->processResult($query->getAllRecords());
 }
Exemplo n.º 5
0
 public function getValues()
 {
     parent::getValues();
     $query = $this->conn->newStatement("\n            SELECT ROUND(SUM(a.profit)) cnt, DATE_FORMAT(a.status_date,'%Y-%m') date, a.manager_id user_id\n            FROM (\n                (SELECT op1.manager_id, op1.creator_id, o1.owner_id, op1.status_date, op1.warehouse_id,\n                    op1.quantity*(op1.price-op1.purchase_price-op1.transport_charges)*IF(o1.user_id=3199,0.5,1) profit\n                FROM order_position op1\n                INNER JOIN `order` o1\n                ON o1.id=op1.order_id\n                WHERE op1.status_id=(SELECT id FROM order_status WHERE code='IS_TRANSFERED'))\n                UNION ALL\n                (SELECT op2.manager_id manager_id, IF(pctp.manager_id=0,op2.creator_id,pctp.manager_id) creator_id, o2.owner_id, op2.status_date, op2.warehouse_id,\n                    IF(pctp.change_type_id IN (11,61),0,pctp.amount) profit\n                FROM order_position op2\n                INNER JOIN price_change_to_position pctp ON pctp.order_position_id=op2.id AND !pctp.deactivated AND !op2.client_price\n                INNER JOIN price_change_type pct ON pctp.change_type_id=pct.id\n                INNER JOIN `order` o2 ON o2.id=op2.order_id\n                WHERE op2.status_id=(SELECT id FROM order_status WHERE code='IS_TRANSFERED'))\n            ) a\n            WHERE a.owner_id=:oid: AND DATE_FORMAT(a.status_date,'%Y-%m')>=:f:\n            AND DATE_FORMAT(a.status_date,'%Y-%m')<=:t: AND a.manager_id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":) \n            GROUP BY a.manager_id, DATE_FORMAT(a.status_date,'%Y-%m')          \n             \n        ");
     $query->setInteger('oid', OWNER_ID);
     $query->setVarChar('f', $this->start);
     $query->setVarChar('t', $this->end);
     foreach ($this->users as $key => $curr) {
         $query->setInteger('uid' . $key, $curr);
     }
     return $this->processResult($query->getAllRecords());
 }
Exemplo n.º 6
0
 public function getValues()
 {
     parent::getValues();
     $query = $this->conn->newStatement("\n            SELECT ROUND(SUM(IF(\n                    !bop.amount,\n                    IF(b.payment_type_id=3,IF(cag.with_vat,0.984,0.98),1)*bo.amount,\n                    IF(bop.change_id,-(1-pct.profit)*bop.amount,IF(bo.type='cancel',-1,1)*(bop.amount*IF(b.payment_type_id=3,IF(cag.with_vat,0.984,0.98),1)-(op.purchase_price+op.transport_charges)*IF(bop.quantity,bop.quantity,op.quantity)))\n                ))*0.1) cnt, DATE_FORMAT(b.datetime,'%Y-%m') date, u.id user_id\n            FROM balance_operation bo\n            INNER JOIN balance_operation_position bop on bop.operation_id=bo.id\n            INNER JOIN balance b on b.id=bo.balance_id\n            INNER JOIN order_position op on op.id=bop.position_id\n            INNER JOIN `order` o ON o.id=op.order_id\n            INNER JOIN client_address ca ON ca.id=o.address_id\n            INNER JOIN client c ON c.id=ca.client_id\n            INNER JOIN pm_employee pe ON pe.user_id=c.manager_id\n            LEFT OUTER JOIN user u ON u.id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":)\n            LEFT OUTER JOIN counteragent cag ON cag.id=bo.seller_id\n            LEFT OUTER JOIN price_change_type pct ON pct.id=bop.change_id\n            WHERE bo.type IN ('cancel','payment','forfeit','markdown') AND c.manager_id=pe.user_id AND o.owner_id=:oid: AND DATE_FORMAT(b.datetime,'%Y-%m')>=:t: AND DATE_FORMAT(b.datetime,'%Y-%m')<=:t:\n            GROUP BY u.id, DATE_FORMAT(b.datetime,'%Y-%m')\n        ");
     $query->setInteger('oid', OWNER_ID);
     $query->setVarChar('f', $this->start);
     $query->setVarChar('t', $this->end);
     foreach ($this->users as $key => $curr) {
         $query->setInteger('uid' . $key, $curr);
     }
     return $this->processResult($query->getAllRecords());
 }
 public function getValues()
 {
     parent::getValues();
     $query = $this->conn->newStatement("\n            SELECT ROUND(SUM(a.profit)) cnt, DATE_FORMAT(a.status_date,'%Y-%m') date, u.id user_id\n            FROM (\n                (SELECT op1.manager_id, op1.creator_id, o1.owner_id, op1.status_date, op1.warehouse_id,\n                    op1.quantity*IF(os.code='IS_RETURNED',-op1.price,op1.price)*IF(o1.user_id=3199,0.5,1) profit, op1.operator_status_id\n                FROM order_position op1\n                INNER JOIN `order` o1 ON o1.id=op1.order_id\n                INNER JOIN order_status os ON os.id=op1.status_id\n                WHERE os.code IN ('IS_RETURNED','IS_TRANSFERED'))\n                UNION ALL\n                (SELECT op2.manager_id manager_id, IF(pctp.manager_id=0,op2.creator_id,pctp.manager_id) creator_id, o2.owner_id, op2.status_date, op2.warehouse_id,\n                    IF(os.code='IS_RETURNED',-pctp.amount,pctp.amount) profit, op2.operator_status_id\n                FROM order_position op2\n                INNER JOIN price_change_to_position pctp ON pctp.order_position_id=op2.id AND !pctp.deactivated AND !op2.client_price\n                INNER JOIN price_change_type pct ON pctp.change_type_id=pct.id\n                INNER JOIN `order` o2 ON o2.id=op2.order_id\n                INNER JOIN order_status os ON os.id=op2.status_id\n                WHERE os.code IN ('IS_RETURNED','IS_TRANSFERED'))\n            ) a\n            LEFT OUTER JOIN user u ON u.id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":) \n            LEFT OUTER JOIN employee_data ed ON ed.user_id=a.operator_status_id\n            LEFT OUTER JOIN warehouse w ON w.id=ed.point_id\n            WHERE a.owner_id=:oid: AND DATE_FORMAT(a.status_date,'%Y-%m')>=:f:\n            AND DATE_FORMAT(a.status_date,'%Y-%m')<=:t: AND (\n                a.creator_id IN (4980,7586) OR\n                w.city_id=63 AND DATE_FORMAT(a.status_date,'%Y-%m')>='2013-10'\n            )\n            GROUP BY u.id, DATE_FORMAT(a.status_date,'%Y-%m')       \n        ");
     $query->setInteger('oid', OWNER_ID);
     $query->setVarChar('f', $this->start);
     $query->setVarChar('t', $this->end);
     foreach ($this->users as $key => $curr) {
         $query->setInteger('uid' . $key, $curr);
     }
     return $this->processResult($query->getAllRecords());
 }
 public function getValues()
 {
     parent::getValues();
     $query = $this->conn->newStatement("\n            SELECT ROUND(SUM(a.profit*0.1)) cnt, DATE_FORMAT(a.status_date,'%Y-%m') date, u.id user_id\n            FROM (\n                (SELECT op1.manager_id, op1.creator_id, o1.owner_id, op1.status_date, op1.warehouse_id,\n                    op1.quantity*(op1.price-op1.purchase_price-op1.transport_charges)*IF(o1.user_id=3199,0.5,1) profit\n                FROM order_position op1\n                INNER JOIN `order` o1 ON o1.id=op1.order_id\n                WHERE op1.status_id=(SELECT id FROM order_status WHERE code='IS_TRANSFERED'))\n                UNION ALL\n                (SELECT op2.manager_id manager_id, IF(pctp.manager_id=0,op2.creator_id,pctp.manager_id) creator_id, o2.owner_id, op2.status_date, op2.warehouse_id,\n                    pctp.amount profit\n                FROM order_position op2\n                INNER JOIN price_change_to_position pctp ON pctp.order_position_id=op2.id AND !pctp.deactivated AND !op2.client_price\n                INNER JOIN price_change_type pct ON pctp.change_type_id=pct.id\n                INNER JOIN `order` o2 ON o2.id=op2.order_id\n                WHERE op2.status_id=(SELECT id FROM order_status WHERE code='IS_TRANSFERED'))\n            ) a\n            LEFT OUTER JOIN user u ON u.id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":)\n            WHERE a.owner_id=:oid: AND DATE_FORMAT(a.status_date,'%Y-%m')>=:f: AND DATE_FORMAT(a.status_date,'%Y-%m')<=:t: AND (\n            \ta.creator_id IN (1937,4868,4864,6976)\n            \tOR a.creator_id=2544 AND DATE_FORMAT(a.status_date,'%Y-%m')='2013-02'\n            \tOR a.creator_id IN (8049,8038,8161,7061) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-08-01'\n            \tOR a.creator_id IN (8407,8599) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-09-01'\n            \tOR a.creator_id IN (8567) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-09-01' AND DATE_FORMAT(a.status_date,'%Y-%m-%d')<'2014-10-01'\n            \tOR a.creator_id IN (8230) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-09-01' AND DATE_FORMAT(a.status_date,'%Y-%m-%d')<'2014-06-01'\n            \tOR a.creator_id IN (8724,8744,8942) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-10-01'\n            \tOR a.creator_id IN (8989) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-11-01'\n            \tOR a.creator_id IN (9358) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-12-01'\n            \tOR a.creator_id IN (9469) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2013-12-01' AND DATE_FORMAT(a.status_date,'%Y-%m-%d')<'2014-06-01'\n            \tOR a.creator_id IN (9970) AND (DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-01-01' AND DATE_FORMAT(a.status_date,'%Y-%m-%d')<'2014-06-01' OR DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-07-01')\n            \tOR a.creator_id IN (10798,10898) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-04-01'\n            \tOR a.creator_id IN (10455) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-04-10'\n            \tOR a.creator_id IN (126) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-04-15'\n            \tOR a.creator_id IN (11217) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-05-01'\n            \tOR a.creator_id IN (11300,11217) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-05-01'\n            \tOR a.creator_id IN (11564) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-07-01'\n            \tOR a.creator_id IN (12690) AND DATE_FORMAT(a.status_date,'%Y-%m-%d')>='2014-10-01'\n           \t)\n            GROUP BY u.id, DATE_FORMAT(a.status_date,'%Y-%m')\n        ");
     $query->setInteger('oid', OWNER_ID);
     $query->setVarChar('f', $this->start);
     $query->setVarChar('t', $this->end);
     foreach ($this->users as $key => $curr) {
         $query->setInteger('uid' . $key, $curr);
     }
     return $this->processResult($query->getAllRecords());
 }
Exemplo n.º 9
0
 public function getValues()
 {
     parent::getValues();
     $query = $this->db->newStatement("\n            SELECT ROUND(0.02*SUM(op.price*op.quantity*IF(o.user_id=3199,0.5,1))) cnt, DATE_FORMAT(op.status_date,'%Y-%m') date, u.id user_id\n            FROM order_position op\n            INNER JOIN `order` o ON o.id=op.order_id\n            INNER JOIN user u ON u.id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":) \n            WHERE o.owner_id=:oid: AND DATE_FORMAT(op.status_date,'%Y-%m')>=:f: \n            AND op.status_id=(SELECT id FROM order_status WHERE code='IS_TRANSFERED')\n            AND DATE_FORMAT(op.status_date,'%Y-%m')<=:t: AND o.payment_type_id=3\n            GROUP BY u.id, DATE_FORMAT(op.status_date,'%Y-%m')          \n             \n        ");
     $query->setInteger('oid', OWNER_ID);
     $query->setVarChar('f', $this->start);
     $query->setVarChar('t', $this->end);
     foreach ($this->users as $key => $curr) {
         $query->setInteger('uid' . $key, $curr);
     }
     return $this->processResult($query->getAllRecords());
 }
Exemplo n.º 10
0
 public function getValues()
 {
     parent::getValues();
     $date = $this->start;
     $results = array();
     while ($date <= $this->end) {
         $query = $this->conn->newStatement("\n                SELECT SUM(IF(d.position_id,op.purchase_price* op.quantity,d.price_purchase*d.quantity)) cnt, u.id user_id, :t:  date\n                FROM defect d\n                LEFT OUTER JOIN order_position op ON op.id=d.position_id\n                LEFT OUTER JOIN `order` o ON o.id=op.order_id\n                LEFT OUTER JOIN product p ON p.id=d.product_id\n                LEFT OUTER JOIN user u ON u.id IN (:uid" . implode(':,:uid', array_keys($this->users)) . ":) \n                WHERE (d.position_id AND o.owner_id=:oid: OR !d.position_id AND p.owner_id=:oid:) AND DATE_FORMAT(d.date_creation,'%Y-%m')<=:t: AND (\n                    DATE_FORMAT(d.product_solved,'%Y-%m')>:t: OR d.product_solved IS NULL\n                    OR d.supposed_compensation AND (DATE_FORMAT(d.supplier_solved,'%Y-%m')>:t: OR d.supplier_solved IS NULL)\n                    OR d.position_id AND (DATE_FORMAT(d.client_solved,'%Y-%m')>:t: OR d.client_solved IS NULL)\n                )\n                GROUP BY u.id, :t:                 \n            ");
         $query->setVarChar('t', $date);
         $query->setInteger('oid', OWNER_ID);
         foreach ($this->users as $key => $curr) {
             $query->setInteger('uid' . $key, $curr);
         }
         $results = array_merge($results, $query->getAllRecords());
         $date = date('Y-m', mktime(0, 0, 0, date('m', strtotime($date . '-01')) + 1, date("01"), date('Y', strtotime($date . '-01'))));
     }
     return $this->processResult($results);
 }
Exemplo n.º 11
0
 public function checkUserLevel()
 {
     try {
         if (Auth::user()) {
             $usersinfo = Auth::user();
             $getIndicatorDescription = Indicator::where('id', '=', $usersinfo->indicator_id)->where('indicator_for', '=', 'STORE')->get();
             if (count($getIndicatorDescription) <= 0) {
                 return 'empty';
             } else {
                 return $getIndicatorDescription;
             }
         } else {
             return 'authFailed';
         }
     } catch (\Exception $e) {
         return 'authErr';
     }
 }
Exemplo n.º 12
0
 public function actionIndex()
 {
     $indicators = Indicator::model()->findAll();
     $this->render('index', array('indicators' => $indicators));
 }
}
if (isset($_POST['indicator'])) {
    if ($_POST['indicator'] == 'balance') {
        //$trace = new Trace($_POST['trace']);
        //$user = $trace->getBaseName();
        //$manager = new Indicator_Manager($user);
        $Ind = new Indicator($_POST['trace']);
        $tA = str_replace(' ', '', $_POST['typeA']);
        $tB = str_replace(' ', '', $_POST['typeB']);
        $TypeObsel = array($tA, $tB);
        if (isset($_POST['after']) && isset($_POST['before'])) {
            $res = json_encode($Ind->balance($_POST['after'], $_POST['before'], $TypeObsel));
        } else {
            $res = json_encode($Ind->balance(null, null, $TypeObsel));
        }
        echo $res;
    }
}
if (isset($_POST['indicator'])) {
    if ($_POST['indicator'] == 'classification') {
        if (isset($_POST['trace'])) {
            $Ind = new Indicator($_POST['trace']);
        }
        if (isset($_POST['after']) && isset($_POST['before'])) {
            $res = json_encode($Ind->classification($_POST['after'], $_POST['before']));
        } else {
            $res = json_encode($Ind->classification(null, null));
        }
        echo $res;
    }
}
function testind()
{
    // $ind = new Indicator("http://localhost:8001/Nice1/t03/");
    // $file = "indic.json";
    // $JS = file_get_contents($file);
    // $json = json_decode($JS,true);
    // $ind->generatefromJson($json);
    // $Ind = new Indicator("http://localhost:8001/Nice1/trace1/");
    // $TypeObsel = array ("Ouverture_Page","Click-Lien");
    // $res = json_encode($Ind->balance('16-04-2014','17-04-2014',$TypeObsel));
    // $res = json_encode($Ind->classification());
    // var_export($res);
    $man = new Indicator_Manager('http://localhost:8001/Nice1/t03/');
    $ind = $man->getIndicator('Recherche Google');
    $I = new Indicator('http://localhost:8001/Nice1/t03/');
    $res = $I->refresh($ind, '04-04-2014');
    var_export($res);
}
Exemplo n.º 15
0
require_once $path_IndicatorStore;
if (isset($_POST['reason'])) {
    if ($_POST['reason'] == 'list') {
        if (isset($_POST['trace'])) {
            $manager = new Indicator_Manager($_POST['trace']);
        }
        $a = $manager->getIndicators();
        $res = json_encode($a);
        echo $res;
    }
    if ($_POST["reason"] == 'addindic') {
        if (isset($_POST['data'])) {
            $ind = $_POST['data'];
        }
        if (isset($_POST['trace'])) {
            $indic = new Indicator($_POST['trace']);
        }
        $res = $indic->generatefromJson($ind);
        echo json_encode($res["val"]);
    }
    if ($_POST['reason'] == 'getin') {
        if (isset($_POST['nameind'])) {
            $name = $_POST['nameind'];
        }
        if (isset($_POST['trace'])) {
            $manager = new Indicator_Manager($_POST['trace']);
        }
        $a = $manager->getIndicator($name);
        if (isset($_POST['trace'])) {
            $ind = new Indicator($_POST['trace']);
        }
Exemplo n.º 16
0
 /**
  * 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 $id the ID of the model to be loaded
  * @return Indicator the loaded model
  * @throws CHttpException
  */
 public function loadModel($id)
 {
     $model = Indicator::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }