示例#1
0
 public function actionSendMail()
 {
     date_default_timezone_set('UTC');
     $startdate = date('Y-m-d H:i:s', strtotime('+1 hours'));
     $enddate = date('Y-m-d H:i:s', strtotime('+2 hours 1 minute'));
     $Poses = Pos::model()->findAll(array('select' => '*', 'condition' => 'date > "' . $startdate . '" and date < "' . $enddate . '"'));
     $users = User::Model()->findAll(array('select' => '*'));
     $subject = 'POS Timer Alert';
     foreach ($Poses as $pos) {
         $message = 'The ' . $pos->type . ' in ' . $pos->location . ' is due out of reinforced at ' . $pos->date . PHP_EOL;
         foreach ($users as $user) {
             $profiles = Profile::model()->findByPk($user->id);
             if ($profiles->subscribe) {
                 $email = $user->email;
                 echo $email . '  ' . $subject . '  ' . $message;
                 UserModule::sendMail($email, $subject, $message);
             }
         }
     }
 }
示例#2
0
文件: Aps.php 项目: ranvijayj/htmlasa
    /**
     * Mark staging item as void (delete item)
     * @return CActiveRecord[]
     */
    public static function MarkStagingItemAsVoid($ap_id)
    {
        // get staging POs
        if ($ap_id != 0) {

            $ap=Aps::model()->findByPk($ap_id);


            $ap->Vendor_ID = 0;
            $ap->AP_Approval_Value = 100;
            $ap->Previous_AP_A_Val = 1;
            $ap->Approved = 1;
            //$ap->Invoice_Amount = 0; ????

            if ($ap->validate()) {
                // begin transaction
                $transaction = Yii::app()->db->beginTransaction();
                try {
                    Pos::generatePdfAddVoid($ap->Document_ID);
                    $ap->save();
                    $transaction->commit();
                } catch(Exception $e) {
                    $transaction->rollback();
                }
            }
        }
    }
示例#3
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $poId = intval($_POST["id"]);
            $po = Pos::model()->with('vendor')->findByPk($poId);

            if ($po) {
                $vendor = $po->vendor;
                if ($vendor) {
                    $client = $vendor->client;
                    $company = $client->company;
                    $addresses = $company->adreses;

                    if (isset($addresses[0])) {
                        $address = $addresses[0];
                        $address->Address1 =  $_POST["Address1"];
                        $address->Address2 =  $_POST["Address2"];
                        $address->City =  $_POST["City"];
                        $address->State =  $_POST["State"];
                        $address->ZIP =  $_POST["ZIP"];
                        $address->Country =  $_POST["Country"];
                        $address->Phone =  $_POST["Phone"];
                        $address->Fax =  $_POST["Fax"];
                        if ($address->validate()) {
                            $address->save();
                            echo "adresses\n";
                        }
                    }

                    if ($company) {
                        $company->Company_Name = $_POST["Company_Name"];
                        $company->Company_Fed_ID = $_POST["Company_Fed_ID"];
                        $company->Email = $_POST["Email"];
                        $company->SSN = $_POST["SSN"];
                        $company->Business_NameW9 = $_POST["Business_NameW9"];
                        if ($company->validate()) {
                            $company->save();
                            echo "company\n";
                        }
                    }
                }

                $po->PO_Account_Number = $_POST["PO_Account_Number"] ? $_POST["PO_Account_Number"] : null;
                $po->PO_Approval_Value = $_POST["PO_Approval_Value"];
                //$po->PO_Delivery_Chg = $_POST["PO_Delivery_Chg"] ? $_POST["PO_Delivery_Chg"] : null;
                //$po->PO_Other_Chg = $_POST["PO_Other_Chg"] ? $_POST["PO_Other_Chg"] : null;
                $po->Export_Batch_ID = $_POST["Export_Batch_ID"] ? $_POST["Export_Batch_ID"] : null;
                $po->PO_Subtotal = $_POST["PO_Subtotal"] ? $_POST["PO_Subtotal"] : null;
                $po->PO_Tax = $_POST["PO_Tax"] ? $_POST["PO_Tax"] : null;
                $po->PO_Total = $_POST["PO_Total"] ? $_POST["PO_Total"] : null;
                $po->PO_Date = $_POST["PO_Date"] ? $_POST["PO_Date"] : null;
                $po->PO_Previous_PO_Val = $_POST["PO_Previous_PO_Val"];
                $po->Payment_Type = $_POST["Payment_Type"];
                $po->PO_Card_Last_4_Digits = $_POST["PO_Card_Last_4_Digits"] ? $_POST["PO_Card_Last_4_Digits"] : null;
                $po->PO_Approved = $_POST["PO_Approved"];
                if ($po->validate()) {
                    $po->save();
                    echo "po\n";
                }

            }
            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'add') {
            die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $apId = intval($_POST["id"]);
            $ap = Aps::model()->findByPk($apId);
            if ($ap) {
                Aps::deleteAP($apId);
            }
            die;
        }

        $conn = mysql_connect(Yii::app()->params->dbhost, Yii::app()->params->dbuser, Yii::app()->params->dbpassword);
        mysql_select_db(Yii::app()->params->dbname);
        mysql_query("SET NAMES 'utf8'");

        Yii::import('ext.phpgrid.inc.jqgrid');

        // set columns
        $col = array();
        $col["title"] = "PO ID"; // caption of column
        $col["name"] = "PO_ID";
        $col["dbname"] = "pos.PO_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Document ID"; // caption of column
        $col["name"] = "Document_ID";
        $col["dbname"] = "pos.Document_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = true;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        $approvalValues = array();
        for ($i = 0; $i <= 100; $i++) {
            $approvalValues[] = $i . ':' . $i;
        }

        $col = array();
        $col["title"] = "PO Approval Value"; // caption of column
        $col["name"] = "PO_Approval_Value";
        $col["dbname"] = "pos.PO_Approval_Value"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>implode(';', $approvalValues));
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Previous PO Val"; // caption of column
        $col["name"] = "PO_Previous_PO_Val";
        $col["dbname"] = "pos.PO_Previous_PO_Val"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>implode(';', $approvalValues));
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Number"; // caption of column
        $col["name"] = "PO_Number";
        $col["dbname"] = "pos.PO_Number"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = false; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Account Number"; // caption of column
        $col["name"] = "PO_Account_Number";
        $col["dbname"] = "pos.PO_Account_Number"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Subtotal"; // caption of column
        $col["name"] = "PO_Subtotal";
        $col["dbname"] = "pos.PO_Subtotal"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        /*$col = array();
        $col["title"] = "PO Tax"; // caption of column
        $col["name"] = "PO_Tax";
        $col["dbname"] = "pos.PO_Tax"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Delivery Chg"; // caption of column
        $col["name"] = "PO_Delivery_Chg";
        $col["dbname"] = "pos.PO_Delivery_Chg"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Other Chg"; // caption of column
        $col["name"] = "PO_Other_Chg";
        $col["dbname"] = "pos.PO_Other_Chg"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;*/

        $col = array();
        $col["title"] = "Export Batch ID"; // caption of column
        $col["name"] = "Export_Batch_ID";
        $col["dbname"] = "pos.Export_Batch_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["search"] = true;
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Total"; // caption of column
        $col["name"] = "PO_Total";
        $col["dbname"] = "pos.PO_Total"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "PO Date"; // caption of column
        $col["name"] = "PO_Date";
        $col["dbname"] = "pos.PO_Date"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $col["formatter"] = "date";
        $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'Y-m-d');
        $cols[] = $col;

        $col = array();
        $col["title"] = "Payment Type"; // caption of column
        $col["name"] = "Payment_Type";
        $col["dbname"] = "pos.Payment_Type"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["edittype"] = "select";
        $col["search"] = true;
        $col["editoptions"] = array("value"=>'OA:OA;CC:CC;DP:DP;CK:CK;PC:PC');
        $cols[] = $col;


        $col = array();
        $col["title"] = "PO Card Last 4 Digits"; // caption of column
        $col["name"] = "PO_Card_Last_4_Digits";
        $col["dbname"] = "pos.PO_Card_Last_4_Digits"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Approved"; // caption of column
        $col["name"] = "PO_Approved";
        $col["dbname"] = "pos.PO_Approved"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["edittype"] = "select";
        $col["search"] = true;
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

        $col = array();
        $col["title"] = "File Name"; // caption of column
        $col["name"] = "File_Name";
        $col["dbname"] = "images.File_Name"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = false; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $col["default"] = "<span class='image_view' data='{Document_ID}'>{File_Name}</span>";
        $cols[] = $col;

        $col = array();
        $col["title"] = "Mime Type"; // caption of column
        $col["name"] = "Mime_Type";
        $col["dbname"] = "images.Mime_Type"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Company ID"; // caption of column
        $col["name"] = "Company_ID";
        $col["dbname"] = "companies.Company_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = false;
        $col["editable"] = false; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Company Name"; // caption of column
        $col["name"] = "Company_Name";
        $col["dbname"] = "companies.Company_Name"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Fed ID"; // caption of column
        $col["name"] = "Company_Fed_ID";
        $col["dbname"] = "companies.Company_Fed_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "SSN"; // caption of column
        $col["name"] = "SSN";
        $col["dbname"] = "companies.SSN"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Email"; // caption of column
        $col["name"] = "Email";
        $col["dbname"] = "companies.Email"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Business_NameW9"; // caption of column
        $col["name"] = "Business_NameW9";
        $col["dbname"] = "companies.Business_NameW9"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Address1"; // caption of column
        $col["name"] = "Address1";
        $col["dbname"] = "addresses.Address1"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Address2"; // caption of column
        $col["name"] = "Address2";
        $col["dbname"] = "addresses.Address2"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "City"; // caption of column
        $col["name"] = "City";
        $col["dbname"] = "addresses.City"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "State"; // caption of column
        $col["name"] = "State";
        $col["dbname"] = "addresses.State"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "ZIP"; // caption of column
        $col["name"] = "ZIP";
        $col["dbname"] = "addresses.ZIP"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Country"; // caption of column
        $col["name"] = "Country";
        $col["dbname"] = "addresses.Country"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Phone"; // caption of column
        $col["name"] = "Phone";
        $col["dbname"] = "addresses.Phone"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Fax"; // caption of column
        $col["name"] = "Fax";
        $col["dbname"] = "addresses.Fax"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["search"] = false;
        $cols[] = $col;


        $g = new jqgrid();

        $grid["caption"] = "PO";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = false;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'companies.Company_Name';
        $grid["sortorder"] = "ASC";
        $grid["add_options"] = array(
            'width'=>'420',
            "closeAfterEdit"=>true, // close dialog after add/edit
            "top"=>"200", // absolute top position of dialog
            "left"=>"200" // absolute left position of dialog
        );

        $g->set_options($grid);

        $g->set_actions(array(
                "add"=>false, // allow/disallow add
                "edit"=>true, // allow/disallow edit
                "delete"=>true, // allow/disallow delete
                "rowactions"=>true, // show/hide row wise edit/del/save option
                "export"=>true, // show/hide export to excel option
                "autofilter" => true, // show/hide autofilter for search
                "search" => "advance" // show single/multi field search condition (e.g. simple or advance)
            )
        );

        $g->select_command = "SELECT   companies.*, addresses.*,
                                       pos.*, images.File_Name, images.Mime_Type
                              FROM pos
                              LEFT JOIN documents ON documents.Document_ID = pos.Document_ID
                              LEFT JOIN images ON images.Document_ID = documents.Document_ID
                              LEFT JOIN vendors ON pos.Vendor_ID = vendors.Vendor_ID
                              LEFT JOIN clients ON clients.Client_ID = vendors.Vendor_Client_ID
                              LEFT JOIN companies ON clients.Company_ID = companies.Company_ID
                              LEFT JOIN company_addresses ON company_addresses.Company_ID = companies.Company_ID
                              LEFT JOIN addresses ON addresses.Address_ID = company_addresses.Address_ID";

        // set database table for CRUD operations
        $g->table = "pos";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'PO_ID', // group starts from this column
                        "numberOfColumns"=>13, // group span to next 13 columns
                        "titleText"=>'PO Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'File_Name', // group starts from this column
                        "numberOfColumns"=>2, // group span to next 2 columns
                        "titleText"=>'Image Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'Company_ID', // group starts from this column
                        "numberOfColumns"=>6, // group span to next 2 columns
                        "titleText"=>'Company Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'Address1', // group starts from this column
                        "numberOfColumns"=>8, // group span to next 2 columns
                        "titleText"=>"Company's Address" // caption of group header
                    )
                )
            )
        );

        // render grid and get html/js output
        $out = $g->render("po");

        $this->render('index',array(
            'out'=>$out,
        ));
	}
示例#4
0
    /**
     * Add document to binder
     * @param $docId
     */
    public static function addDocumentToBinder($docId)
    {
        $document = Documents::model()->findByPk($docId);
        if ($document) {
            $year = substr($document->Created, 0, 4);
            Storages::createProjectStorages($document->Project_ID, $year);
            $subsectionId = 0;
            if ($document->Document_Type == Documents::PM) {
                $payment = Payments::model()->findByAttributes(array(
                    'Document_ID' => $docId,
                ));
                $year = substr($payment->Payment_Check_Date, 0, 4);
                $subsectionId = Sections::createLogBinder($document->Project_ID, $document->Document_Type, $year);
            } elseif ($document->Document_Type == Documents::PO) {
                $po = Pos::model()->findByAttributes(array(
                    'Document_ID' => $docId,
                ));
                $year = substr($po->PO_Date, 0, 4);
                $subsectionId = Sections::createLogBinder($document->Project_ID, $document->Document_Type, $year);
                if ($po->PO_Backup_Document_ID != 0) {
                    $bu = LibraryDocs::model()->findByAttributes(array(
                        'Document_ID' => $po->PO_Backup_Document_ID,
                        'Subsection_ID' => $subsectionId,
                    ));
                    if (!$bu) {
                        $libDoc = new LibraryDocs();
                        $libDoc->Document_ID = $po->PO_Backup_Document_ID;
                        $libDoc->Subsection_ID = $subsectionId;
                        $libDoc->Access_Type = Storages::HAS_ACCESS;
                        $libDoc->Sort_Numb = 0;
                        if ($libDoc->validate()) {
                            $libDoc->save();
                        }
                    }
                }
            }

            $libDoc = LibraryDocs::model()->findByAttributes(array(
                'Document_ID' => $docId,
                'Subsection_ID' => $subsectionId,
            ));

            if (!$libDoc) {
                $libDoc = new LibraryDocs();
                $libDoc->Document_ID = $docId;
                $libDoc->Subsection_ID = $subsectionId;
                $libDoc->Access_Type = Storages::HAS_ACCESS;
                $libDoc->Sort_Numb = 0;
                if ($libDoc->validate()) {
                    $libDoc->save();
                }
            }

            LibraryDocs::sortDocumentsInSubsection($subsectionId);
        }
    }
 public function postPos()
 {
     $q = strtolower(Input::get('term'));
     if (!$q) {
         return;
     }
     $data['response'] = 'false';
     $query = Pos::where('pos_id', 'LIKE', "%{$q}%")->orWhere('pos_description', 'LIKE', "%{$q}%")->get();
     if ($query) {
         $data['message'] = array();
         $data['response'] = 'true';
         foreach ($query as $row) {
             $records = $row->pos_description . ' (' . $row->pos_id . ')';
             $data['message'][] = array('label' => $records, 'value' => $row->pos_id);
         }
     }
     echo json_encode($data);
 }
示例#6
0
<?php

$this->pageTitle = Yii::app()->name;
?>

<h1><?php 
echo Yii::app()->params['indexHeader'];
?>
 </h1>

<?php 
date_default_timezone_set('UTC');
$model = new Pos();
if (!Yii::app()->user->isGuest or !Yii::app()->params['requireLogin']) {
    $this->widget('zii.widgets.grid.CGridView', array('id' => 'index-grid', 'dataProvider' => $model->getAll(), 'enableSorting' => true, 'selectableRows' => 0, 'rowCssClassExpression' => '$data->friendly == "No" ? "removed" : "added"', 'columns' => array(array('class' => 'CLinkColumn', 'labelExpression' => '"<b>".$data->location."</b>"', 'urlExpression' => '"http://evemaps.dotlan.net/system/".$data->location', 'header' => 'Location', 'linkHtmlOptions' => array('style' => 'color: white;', 'target' => '_blank')), 'type', 'cycle', 'planet', 'moon', 'alliance', 'friendly', 'date', array('name' => 'Time Remaining', 'value' => '$data->php5_2_date_diff("NOW", $data->date)')), 'htmlOptions' => array('style' => 'color: black;')));
} else {
    echo 'You must log in to view the Timer information';
}
示例#7
0
    /**
     * Generate or regenerate PDF for AP using FPDF library
     * @param $apId
     * @param bool $approved
     */
    public static function generatePdfFpdf($doc_id, $doc_type, $approved = false)
    {


        if ( $doc_type == 'AP' ) {
            // get AP
            $ap = Aps::model()->with('dists', 'document', 'ck_req_detail')->findByAttributes(
                array('Document_ID' => $doc_id)
            );

            $ckRequest = $ap->ck_req_detail;

            // get PO dists
            $apDists = $ap->dists;

            // get PO formatting
            $poFormatting = PoFormatting::model()->findByAttributes(array(
                'Project_ID' => $ap->document->Project_ID,
            ));

            // get Sign_Requested_By user info
            $signRequestedByUser = Users::model()->with('person')->findByPk($ckRequest->Sign_Requested_By);

            $aproval_detail_list = Audits::getApprovalDetailList($ap->Document_ID);
            // get current vendor info
            $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($ap->Vendor_ID);

            $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
            $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

            $pdf = new FpdfAp('P','mm','Letter');

            $pdf->AddFont('HelveticaB','','helveticab.php');
            $pdf->AddFont('Courier','','courier.php');
            $pdf->AddFont('CourierB','','courierb.php');
            $pdf->SetAutoPageBreak(true, 10);

            $pdf->setVariables($ap,$poFormatting,$ckRequest,$apDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved);
            $pdf->AliasNbPages();
            $pdf->setPageNo(1);
            //$pdf->AliasNbPages();
            $pdf->AddPage('P');
            $pdf->SetFont('Helvetica','',13.5);
            $pdf->SetXY(5,10);
            $pdf->PrintContent();

            //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
            $fileName = 'ApTempPdf'.date('Y-m-d h:i:s').'.pdf';
            $filepath = Helper::createDirectory('ap');
            $filepath = Helper::createDirectory('ap/'.Yii::app()->user->clientID);
            $filepath.= '/'.$fileName;
            $pdf->Output($filepath, 'F');
            //$pdf->Output();

            $last_page = $pdf->custom_page_num;



            $pdf->Close();
        }
        if (( $doc_type == 'PO' )) {

            $po = Pos::model()->findByAttributes(
                array('Document_ID' => $doc_id)
            );

            // get PO dists
            $poDists = $po->dists;

            // get PO details
            $poDecrDetails = $po->decr_details;

            // get PO formatting
            $poFormatting = PoFormatting::model()->findByAttributes(array(
                'Project_ID' => $po->document->Project_ID,
            ));

            // get Sign_Requested_By user info
            $signRequestedByUser = Users::model()->with('person')->findByPk($po->Sign_Requested_By);

            $aproval_detail_list = Audits::getApprovalDetailList($po->Document_ID);

            // get current vendor info
            $currentVendor = Vendors::model()->with('client.company.adreses')->findByPk($po->Vendor_ID);

            $condition = UsersClientList::getClientAdminCondition($currentVendor->client->Client_ID);
            $vendorAdmin = UsersClientList::model()->with('user.person')->find($condition);

            $paymentTypes = array(
                'OA' => 'On Account',
                'CC' => 'Credit Card',
                'DP' => 'Deposit',
                'CK' => 'Payment Check',
                'PC' => 'Petty Cash',
            );


            $pdf = new FpdfPo('P','mm','Letter');

            $pdf->AddFont('HelveticaB','','helveticab.php');
            $pdf->AddFont('Courier','','courier.php');
            $pdf->AddFont('CourierB','','courierb.php');
            $pdf->SetAutoPageBreak(true, 10);

            $pdf->setVariables($po,$poFormatting,$poDecrDetails,$poDists,$currentVendor,$vendorAdmin,$signRequestedByUser,$aproval_detail_list,$approved,$paymentTypes);
            $pdf->AliasNbPages();
            $pdf->setPageNo(1);
            //$pdf->AliasNbPages();
            $pdf->AddPage('P');
            $pdf->SetFont('Helvetica','',13.5);
            $pdf->SetXY(5,10);
            $pdf->PrintContent();

            //$path=Helper::createDirectory('batches');// creates directory "protected/data/batches" if not exists
            $fileName = 'TempFile.pdf';
            $filepath = Helper::createDirectory('po');
            $filepath = Helper::createDirectory('po/'.Yii::app()->user->clientID);
            $filepath.= '/'.$fileName;
            $pdf->Output($filepath, 'F');
            //$pdf->Output();

            $last_page = $pdf->custom_page_num;
            $pdf->Close();
        }


        return array(
          'path' => $filepath,
          'pages'=> $last_page
        );
    }
示例#8
0
    /**
     * Function checks document approval value and returns true if it is <2
     * it also returns true for non AP and PO
     * @param $doc_model
     * @return boolean
     */
    public static function checkReassigmentPossibility($doc_model) {
        if($doc_model->Document_Type == 'AP' || $doc_model->Document_Type == 'AP') {
            if($doc_model->Document_Type == 'AP') {
                $ap =Aps::model()->findByAttributes(array(
                    'Document_ID' => $doc_model->Document_ID
                ));

                if ($ap->AP_Approval_Value < 2 && $ap->Approved==0) {
                    $result = true;
                } else {
                    $result = false;
                }
            }

            if($doc_model->Document_Type == 'PO') {
                $po =Pos::model()->findByAttributes(array(
                    'Document_ID' => $doc_model->Document_ID
                ));

                if ($po->PO_Approval_Value < 2 && $po->Approved == 0) {
                    $result = true;
                } else {
                    $result = false;
                }
            }

        } else {
            $result = true;
        }


        return $result;
    }
示例#9
0
<span class="sidebar_block_header">Details:</span>

<?php

    if ($appr->DocType=='PO') {
        $po = Pos::model()->with('document')->findByPk($appr->ID);
        $poFormatting = PoFormatting::model()->findByAttributes(array(
            'Project_ID' => $po->document->Project_ID));

        //finding page in data entry array
        $page=0;
        if ($is_dec) {

            // get po to enter data
            $pos = Pos::model()->findPOToEntry();
            //var_dump($pos);
            //var_dump($docId);
            //die;


                $i=1;
                foreach($pos as $po) {
                    if ($po->Document_ID == $docId) {
                    $page=$i;
                    }
                    $i++;
                }
            $dec_link='/dataentry/po?page='.$page;
            if($page==0) {$mess = 'Data entry for this item not available for you';
            } else {$mess = '<a href="'.$dec_link.'"> Open item for data entry</a>';}
        }
示例#10
0
    public function appendPosList ($client_id,$project_list,$doc_type){

        $condition = new CDbCriteria();
        $condition->condition =' documents.Client_ID = '.$client_id;
        $condition->addInCondition('documents.Project_ID ',$project_list);
        $condition->join = 'left join documents on documents.Document_ID = t.Document_ID';

        $models = Pos::model()->with('document')->findAll($condition);

        $xml_doc = $this->xml->createElement("document");
        if($models) {
            foreach ($models as $model) {
                $xml_row = $this->xml->createElement("row");

                foreach ($model->attributes as $key => $value) {
                    $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1'));
                    $xml_field->setAttribute('name', $key);
                    $xml_row->appendChild($xml_field);
                }

                //+ we need to insert several columns from document model
                    $xml_field = $this->xml->createElement("field",htmlentities($model->document->Origin,ENT_QUOTES | 'ENT_XML1'));
                    $xml_field->setAttribute('name', 'DocumentsOrigin');
                    $xml_row->appendChild($xml_field);
                            $xml_field = $this->xml->createElement("field",htmlentities($model->document->Created,ENT_QUOTES | 'ENT_XML1'));
                            $xml_field->setAttribute('name', 'DocumentsCreated');
                            $xml_row->appendChild($xml_field);
                                    $xml_field = $this->xml->createElement("field",htmlentities($model->document->Project_ID,ENT_QUOTES | 'ENT_XML1'));
                                    $xml_field->setAttribute('name', 'DocumentsProject_ID');
                                    $xml_row->appendChild($xml_field);
                // end of block

                /*documents processing*/
                $xml_doc_row = $this->xml->createElement("documents");
                foreach ($model->document->attributes as $key => $value) {
                    $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1'));
                    $xml_field->setAttribute('name', $key);
                    $xml_doc_row->appendChild($xml_field);
                }
                /*end of documents processing*/


                /*bacups processing*/

                $bacup = Documents::model()->findByPk($model->PO_Backup_Document_ID);
                $xml_backup_row = $this->xml->createElement("backup");
                if ($bacup){
                    foreach ($bacup->attributes as $key => $value) {
                        $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1'));
                        $xml_field->setAttribute('name', $key);
                        $xml_backup_row->appendChild($xml_field);
                    }
                }
                /*end of bacups processing*/

                /*po descriptions connected processing*/
                $xml_desc = $this->xml->createElement("po_desc_detail");
                foreach ($model->decr_details as $descs) {
                    $xml_dist_row = $this->xml->createElement("desc_row");

                    foreach ($descs as $key=>$value) {
                        $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1'));
                        $xml_field->setAttribute('name', $key);
                        $xml_dist_row->appendChild($xml_field);
                    }
                    $xml_desc->appendChild($xml_dist_row);
                /*end of descriptions processing*/

                /*dists processing*/
                $xml_dists = $this->xml->createElement("po_dists");
                foreach ($model->dists as $dist) {
                    $xml_dist_row = $this->xml->createElement("dist_row");

                    foreach ($dist as $key=>$value) {
                        $xml_field = $this->xml->createElement("field",htmlentities($value,ENT_QUOTES | 'ENT_XML1'));
                        $xml_field->setAttribute('name', $key);
                        $xml_dist_row->appendChild($xml_field);
                    }



                    $xml_dists->appendChild($xml_dist_row);
                }

                /*end of dists processing*/


                /*images processing*/
                $xml_image_row = $this->xml->createElement("images");
                $xml_field = $this->xml->createElement("field",$model->document->image->Image_ID);
                $xml_field->setAttribute('name', 'Image_ID');
                $xml_image_row->appendChild($xml_field);

                $filename = FileModification::prepareFileForExport($model->document->image->Document_ID,$doc_type,$this->filepath);
                $xml_field = $this->xml->createElement("field",$filename);
                $xml_field->setAttribute('name', 'File_Name');
                $xml_image_row->appendChild($xml_field);
                    $xml_row->appendChild($xml_field);

                $xml_field = $this->xml->createElement("field",$model->document->image->Mime_Type);
                $xml_field->setAttribute('name', 'Mime_Type');
                $xml_image_row->appendChild($xml_field);
                    $xml_row->appendChild($xml_field);

                $xml_field = $this->xml->createElement("field",$model->document->image->Pages_Count);
                $xml_field->setAttribute('name', 'Pages_Count');
                $xml_image_row->appendChild($xml_field);
                    $xml_row->appendChild($xml_field);
                /*end of images processing*/

                $xml_row->appendChild($xml_dists);
                $xml_row->appendChild($xml_desc);
                $xml_row->appendChild($xml_backup_row);
                $xml_row->appendChild($xml_doc_row);
                $xml_row->appendChild($xml_image_row);
                $xml_doc->appendChild($xml_row);


            }



            $this->wrapper->appendChild($xml_doc);


        }
    }
    }
示例#11
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 = Pos::model()->findByPk((int) $id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
示例#12
0
 public function actionRssfeed()
 {
     // Don't Publish the RSS Feed if the Site index requires a login
     if (Yii::app()->params['requireLogin']) {
         return;
     }
     // OK to publish an RSS feed of Active Timers
     // get All the timers
     $model = new Pos();
     $poslist = $model->findAll();
     Yii::import('ext.feed.*');
     // Create a feed object
     // RSS 2.0 is the default type
     $feed = new EFeed();
     // Set the title to Match the Web Site
     $feed->title = Yii::app()->name;
     $feed->description = Yii::app()->params['indexHeader'];
     $sitename = str_replace('localhost', '127.0.0.1', Yii::app()->getBaseUrl($absolute = true));
     $feed->setLink($sitename);
     // add an item for each POS
     if (count($poslist)) {
         foreach ($poslist as $pos) {
             $item = $feed->createNewItem();
             $item->title = $pos->type . ' in ' . $pos->location . ' is due out of ' . $pos->cycle . ' cycle at ' . $pos->date;
             $item->link = Yii::app()->getBaseUrl($absolute = true) . '?=' . $pos->id;
             $item->date = $pos->date;
             $item->addTag('guid', Yii::app()->getBaseUrl($absolute = true) . '?=' . $pos->id, array('isPermaLink' => 'true'));
             $feed->addItem($item);
         }
     } else {
         //nothing to add
         $item = $feed->createNewItem();
         $item->title = "No Timers posted";
         $item->link = Yii::app()->getBaseUrl($absolute = true) . '?=' . $pos->id;
         $item->date = date(DATE_RFC822);
         $feed->addItem($item);
     }
     $feed->addChannelTag('language', 'en-us');
     $feed->addChannelTag('pubDate', date(DATE_RSS, time()));
     // generate the feed and display it
     $feed->generateFeed();
     // Dont need to render anything
     //$this->render('rssfeed',array('feed'=>$feed));
 }
示例#13
0
文件: Pos.php 项目: ranvijayj/htmlasa
    public static function notifyNextUsers($nextUsers,$userApprovalRange){
        if ($nextUsers) {
            $project = Projects::model()->findByPk(Yii::app()->user->projectID);
            foreach ($nextUsers as $nextUser ) {
                $nextUserId = $nextUser->User_ID;
                $nextUserApprovalValue = $nextUser->User_Approval_Value;

                $user = Users::model()->with('settings','person')->findByPk($nextUserId);

                // send notification

                // get pos to approve to next users
                $condition = new CDbCriteria();
                $condition->join = "LEFT JOIN documents ON documents.Document_ID=t.Document_ID";
                $condition->condition = "documents.Client_ID='" . Yii::app()->user->clientID . "'";
                $condition->addCondition("documents.Project_ID = '" . Yii::app()->user->projectID . "'");
                $condition->addCondition("t.PO_Approval_Value < '" . $nextUserApprovalValue . "'");
                $condition->addCondition("t.PO_Approval_Value >= '" . $userApprovalRange['user_appr_val'] . "'");
                $condition->addCondition("t.PO_Approval_Value != '0'");
                $pos = Pos::model()->find($condition);
                if ($pos) {
                    $client = Clients::model()->findByPk(Yii::app()->user->clientID);
                    $clientsToApprove = array($client->company->Company_Name.' - '.$project->Project_Name.'');

                    Mail::sendPendingApprovalDocumentsNotification(!$user->settings->Notification,$user,$clientsToApprove, Documents::PO,$client,$project);
                }
            }
        }
    }
示例#14
0
 public function actionSimpan($id)
 {
     $return = array('sukses' => false, 'error' => array('code' => '500', 'msg' => 'Sempurnakan input!'));
     if (isset($_POST['pos'])) {
         $pos = Pos::model('Pos')->findByPk($id);
         $i = 1;
         /* Simpan, jiga gagal dicoba max 3 kali */
         while ($pos->status == Penjualan::STATUS_DRAFT && $return['sukses'] == false && $i <= 3) {
             $return = $pos->simpanPOS($_POST['pos']);
             $i++;
         }
         if ($return['sukses']) {
             if ($this->isOtorisasiAdmin($id)) {
                 $this->adminLogout();
             }
         }
     }
     $this->renderJSON($return);
 }