コード例 #1
0
    public function getMSTaskChartData($id)
    {
        $criteria=new CDbCriteria;        
        $criteria->order='details asc';
        $criteria->compare('LCASE(order_id)',strtolower($id),true);
        
        $milestones = Milestone::model()->findAll($criteria);
        $chartData = array();
//        $chartRow = array('Ms/Task','Details','Start','End');
//        $chartData[] = $chartRow;
        $chartRow = array();
        $dateformat = Yii::app()->controller->datetimemysqlformatDMY;
        foreach($milestones as $milestone)
        {
            $start_at = Yii::app()->controller->getMysqlFormattedDatetime($milestone->start_at, $dateformat, false);
            //$end_at = Yii::app()->controller->getMysqlFormattedDatetime($milestone->end_at, $dateformat, false);            
            $chartRow[] = $milestone->details;
            $info = $start_at;
            $chartRow[] = $info;//this info field.
            $chartRow[] = $start_at;
            $chartRow[] = $start_at;
            $chartData[] = $chartRow;
            $chartRow = array();
        }
        
        $criteria=new CDbCriteria;
        $criteria->with = array('task');
        $criteria->order='task.name asc';
        $criteria->compare('LCASE(t.order_id)',strtolower($id),true);
        $ordertasks = Ordertask::model()->findAll($criteria);
        foreach($ordertasks as $ordertask)
        {
            $completed = $ordertask->completed;
            $start_at = Yii::app()->controller->getMysqlFormattedDatetime($ordertask->start_at, $dateformat, false);
            $end_at = Yii::app()->controller->getMysqlFormattedDatetime($ordertask->end_at, $dateformat, false);
            if($start_at === $end_at)
            {
                $datetime = new DateTime($ordertask->start_at);
                $datetime->modify('+24 hour');
                $end_at = $datetime->format($dateformat);
            }
            $info = ' [ ' . $completed . '% ] '. $start_at . ' - ' . $end_at;
            $chartRow[] = $ordertask->task->name;
            $chartRow[] = $info;//this info field.
            $chartRow[] = $start_at;
            $chartRow[] = $end_at;
            $chartData[] = $chartRow;
            $chartRow = array();
        }
//        $datetime = new DateTime('today');       
//        $datestr = $datetime->format($this->datetimemysqlformatDMY);
//        $low = $datestr;
//        $datetime->modify('+2 day');
//        $datestr = $datetime->format($this->datetimemysqlformatDMY);
//        $high = $datestr;
//        ["testms1", 
//            0, 
//            Object { date="2014-08-21 00:00:00", timezone_type=3,
//            timezone="Singapore"}, Object { date="2014-08-21 00:00:00", timezone_type=3,
//            timezone="Singapore"}                
//        ]
//        $chartData = array();
//        $chartRow = array();
//        $chartRow[] = 'MS-1';
//        $chartRow[] = $low;
//        $chartRow[] = $low;
//        $chartData[] = $chartRow;
//        $chartRow = array();
//        $chartRow[] = 'MS-2';
//        $chartRow[] = $low;
//        $chartRow[] = $high;
//        $chartData[] = $chartRow;
        return $chartData;
    }
コード例 #2
0
 public function renderPCTypeDashboard()
 {
     $ordertask =new Ordertask('search');
     $ordertask->unsetAttributes();  // clear any default values
     
     $milestone =new Milestone('search');
     $milestone->unsetAttributes();  // clear any default values
     
     $orderlistLookup = Yii::app()->controller->getOrdersLookup();
     if(!empty($orderlistLookup))
     {
         $tmp = array_keys($orderlistLookup);
         $ordertask->order_id = $tmp[0];
         $milestone->order_id = $tmp[0];
     }
     if(isset($_GET['Ordertask']))
         $ordertask->attributes=$_GET['Ordertask'];
     
     if(isset($_GET['Milestone']))
         $milestone->attributes=$_GET['Milestone'];
     
     $payinmodel =new Payment('search');
     $payinmodel->unsetAttributes();  // clear any default values
     if(isset($_GET['Payment']))
         $payinmodel->attributes=$_GET['Payment'];
     
     $totalAR = 0;
     $totalAP = 0;
     $totalCash = 0;
     $accountchart = $this->getAccountChart($totalAR, $totalAP, $totalCash);
     $mschart = $this->getMSTaskChart($milestone->order_id);
     $this->render( $this->getView('index','index'),
                     array(
                         'ordertask' => $ordertask,
                         'milestone'=>$milestone,
                         'orderlistLookup' => $orderlistLookup,
                         'accountchart' => $accountchart,
                         'mschart' => $mschart,
                         'payinmodel'=>$payinmodel,
                         'totalAR' => $totalAR,
                         'totalAP' => $totalAP,
                         'totalCash' => $totalCash,
                         )
                 );
 }
コード例 #3
0
ファイル: Menu.php プロジェクト: Rajagunasekaran/BACKUP
 private function getListsForAccountCrud(&$rec){
     $except = array();
     $rec["allcustomers"] = array();
     $allcustomersresult = \Person::find('all', array('conditions' => array('type=?', Menu::ppl_type_customer), 'order' => 'name asc'));
     //'customerorders' => array('include' => array('orderproducts'=>array('include'=>array('product'))))
     foreach ($allcustomersresult as $allcustomersrec) {
          $allcustomersrecary = $allcustomersrec->to_array(array('include' => array('ofcaddresses','customerorders' => array('include' => array('orderproducts'=>array('include'=>array('product')), 'araccounts', 'apaccounts','blngaddresses','shpngaddresses') )), 'except' => $except));
          $rec["allcustomers"][] = $allcustomersrecary;
     }
     $rec["allcontractors"] = array();
     $allcontractorsresult = \Person::find('all', array('conditions' => array('type=?', Menu::ppl_type_contractor), 'order' => 'name asc'));
     foreach ($allcontractorsresult as $allcontractorrec) {
          $allcontractorrecary = $allcontractorrec->to_array(array('include' => array('ofcaddresses','externalordertasks' => array('include' => array('accounts','order','task'))), 'except' => $except));
          $rec["allcontractors"][] = $allcontractorrecary;
     }
     $rec["allsuppliers"] = array();
     $allsplrsresult = \Person::find('all', array('conditions' => array('type=?', Menu::ppl_type_supplier), 'order' => 'name asc'));
     $tmpinclude = array('supplierpurchases'=> array('include' => array('purchaseproducts'=>array('include'=>array('product')), 'araccounts', 'apaccounts') ));
     foreach ($allsplrsresult as $allsplrrec) {
          $allsplrrecary = $allsplrrec->to_array(array('include' => $tmpinclude, 'except' => $except));
          $rec["allsuppliers"][] = $allsplrrecary;
     }
     $rec["allemployees"] = array();
     $allempresult = \Person::find('all', array('conditions' => array('type=?', 'employee'), 'order' => 'name asc'));
     foreach ($allempresult as $allemprec) {
          $allemprecary = $allemprec->to_array(array('except' => $except));
          $rec["allemployees"][] = $allemprecary;
     }
     $this->getAllOrders($rec, $except);
     $rec["allordertasks"] = array();
     $allordertasksresult = \Ordertask::find('all', array('conditions' => array(), 'order' => 'order_id, task_id asc'));
     foreach ($allordertasksresult as $allordertasksrec) {
          $allordertasksrecary = $allordertasksrec->to_array(array('except' => $except));
          $rec["allordertasks"][] = $allordertasksrecary;
     }
     $this->getConfigs($rec);
 }
コード例 #4
0
    /**
     * Deletes a particular model.
     * If deletion is successful, the browser will be redirected to the 'admin' page.
     * @param integer $id the ID of the model to be deleted
     */
    public function actionDelete( $id )
    {
        if ( Yii::app()->request->isPostRequest )
        {
// we only allow deletion via POST request
            $model = $this->loadModel( $id );
            if(empty($model->payments))
            {
                foreach($model->accountorders as $single)
                {
                    $orderid = $single->order_id;
                    $ordertaskid = $single->ordertask_id;
                    $ordertask = Ordertask::model()->findByPk($ordertaskid);
                    if(!empty($ordertask))
                    {
                        $ordertask->invstatus = Helper::CONST_INVSTS_UNINVOICED;
                        $rtn = $ordertask->save();
                    }
                    else
                    {
                        $order = Order::model()->findByPk($orderid);
                        if(!empty($order))
                        {
                            $order->invstatus = Helper::CONST_INVSTS_UNINVOICED;
                            $rtn = $order->save();
                        }
                    }
                    if($rtn)
                    {
                        $rtn = $single->delete();
                    }                    
                    if(!$rtn) break;
                }
                if($rtn)
                {
                   foreach($model->accountpurchases as $single)
                    {
                        $rtn = $single->delete();
                        if(!$rtn) break;
                    }
                }
                if($rtn)
                {
                    $rtn = $model->delete();
                }
                if($rtn)
                {
                    $message = 'Invoice Deleted';                    
                }
                else
                {
                    $message = 'Invoice delete Failed';
                }
            }
            else
            {
                $message = 'Delete all Payments first';
            }
            if (Yii::app()->request->isAjaxRequest)
            {
                if ( !isset( $_GET['ajax'] ) )
                {
                    $RetCode = 0;
                    $data = Yii::app()->createUrl('account/admin');
                    $this->returnJsonResponse($RetCode, $data, $message);
                }
            }
// if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
            if ( !isset( $_GET['ajax'] ) )
                $this->redirect( isset( $_POST['returnUrl'] ) ? $_POST['returnUrl'] : array( 'admin' ) );
        }
        else
            throw new CHttpException( 400, 'Invalid request. Please do not repeat this request again.' );
    }
コード例 #5
0
 public function saveToDB($model, $oldpayment)
 {
     $rtn = false;
     $trans = Yii::app()->db->beginTransaction();
     try 
     {                                    
         $orderid = $model->order_or_ot_id;
         $ordertaskid = 0;
         $curdirection = $model->direction;
         $rtn = true;
         if(strtolower($curdirection) === strtolower(Helper::CONST_Outwards))
         {
             $ordertask = Ordertask::model()->findByPk($orderid);
             $rtn = !empty($ordertask);
             if($rtn)
             {
                 $ordertaskid = $ordertask->id;
                 $orderid = $ordertask->order->id;
             }
         }
         if($rtn)
         {
             $model->order_id = $orderid;
             $model->ordertask_id = $ordertaskid;
             $rtn = $model->save();
             if($rtn)
             {
                 $accountid = $model->account_id;
                 $rtn = $this->updateAccountPaid($oldpayment, $model->amount, $accountid);
             }
         }
     }
     catch (Exception $e) 
     {
         Yii::log("Error occurred while saving/activating order. Rolling back... . Failure reason as reported in exception: " . $e->getMessage(), CLogger::LEVEL_ERROR, __METHOD__);
         $rtn = false;
     }
     if($rtn)
     {
         $trans->commit();
     }
     else
     {
         $trans->rollback();
         Yii::app()->user->setFlash('error', "Error occurred");
     }
     return $rtn;
 }
コード例 #6
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 the ID of the model to be loaded
*/
public function loadModel($id)
{
$model=Ordertask::model()->findByPk($id);
if($model===null)
throw new CHttpException(404,'The requested page does not exist.');
return $model;
}