Пример #1
2
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $documentId = intval($_POST["id"]);
            $document = Documents::model()->with('images', 'user')->findByPk($documentId);

            if ($document) {
                $user = $document->user;
                $image = $document->image;

                if ($user) {
                    $person = $user->person;
                    $addresses = $person->adresses;

                    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";
                        }
                    }

                    $user->User_Login = $_POST["User_Login"];
                    $user->User_Type = $_POST["User_Type"];
                    $user->Last_Login = $_POST["Last_Login"] ? $_POST["Last_Login"] : null;
                    $user->Active = intval($_POST["Active"]);
                    if ($user->validate()) {
                        $user->save();
                        echo "user\n";
                    }

                    $person->First_Name = $_POST["First_Name"];
                    $person->Last_Name = $_POST["Last_Name"];
                    $person->Email = $_POST["Email"];
                    $person->Mobile_Phone = $_POST["Mobile_Phone"];
                    $person->Direct_Phone = $_POST["Direct_Phone"];
                    $person->Direct_Fax = $_POST["Direct_Fax"];
                    if ($person->validate()) {
                        $person->save();
                        echo "person\n";
                    }
                }

                $document->Created = $_POST["Created"];
                if ($document->validate()) {
                    $document->save();
                    echo "document\n";
                }
/*
                $image->File_Name = $_POST["File_Name"];
                if ($image->validate()) {
                    $image->save();
                    echo "image\n";
                }
*/
            }

            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $documentId = intval($_POST["id"]);
            $document = Documents::model()->findByPk($documentId);
            if ($document) {
                Documents::deleteDocument($documentId);
            }
            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"] = "Document ID"; // caption of column
        $col["name"] = "Document_ID";
        $col["dbname"] = "documents.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"] = false;
        $col["viewable"] = true;
        $col["search"] = false;
        $col["sortable"] = false;
        $cols[] = $col;

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

        $col = array();
        $col["title"] = "Created"; // caption of column
        $col["name"] = "Created";
        $col["dbname"] = "documents.Created"; // 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"] = "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"] = "User ID"; // caption of column
        $col["name"] = "User_ID";
        $col["dbname"] = "documents.User_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;

        $col = array();
        $col["title"] = "Default Project"; // caption of column
        $col["name"] = "Default_Project";
        $col["dbname"] = "users.Default_Project"; // 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;

        $col = array();
        $col["title"] = "User Login"; // caption of column
        $col["name"] = "User_Login";
        $col["dbname"] = "users.User_Login"; // 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"] = "User Type"; // caption of column
        $col["name"] = "User_Type";
        $col["dbname"] = "users.User_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["editoptions"] = array("value"=>'User:User;Admin:Admin;DB Admin:DB Admin;Data Entry Clerk:Data Entry Clerk');
        $cols[] = $col;

        $col = array();
        $col["title"] = "Last Login"; // caption of column
        $col["name"] = "Last_Login";
        $col["dbname"] = "users.Last_Login"; // 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"] = "Active"; // caption of column
        $col["name"] = "Active";
        $col["dbname"] = "users.Active"; // 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;
        $col["sortable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

        $col = array();
        $col["title"] = "Last_IP"; // caption of column
        $col["name"] = "Last_IP";
        $col["dbname"] = "users.Last_IP"; // 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"] = false;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Person ID"; // caption of column
        $col["name"] = "Person_ID";
        $col["dbname"] = "persons.Person_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;

        $col = array();
        $col["title"] = "First Name"; // caption of column
        $col["name"] = "First_Name";
        $col["dbname"] = "persons.First_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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Last Name"; // caption of column
        $col["name"] = "Last_Name";
        $col["dbname"] = "persons.Last_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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Email"; // caption of column
        $col["name"] = "Email";
        $col["dbname"] = "persons.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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Mobile Phone"; // caption of column
        $col["name"] = "Mobile_Phone";
        $col["dbname"] = "persons.Mobile_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"] = "Direct Phone"; // caption of column
        $col["name"] = "Direct_Phone";
        $col["dbname"] = "persons.Direct_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;
        $col["search"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Direct Fax"; // caption of column
        $col["name"] = "Direct_Fax";
        $col["dbname"] = "persons.Direct_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;

        // set columns
        $col = array();
        $col["title"] = "Address ID"; // caption of column
        $col["name"] = "Address_ID";
        $col["dbname"] = "addresses.Address_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;

        $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"] = "Documents";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'documents.Document_ID';
        $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   addresses.*, persons.*, users.Default_Project,
                                       users.User_Login, users.User_Type, users.Last_Login, users.Active,
                                       users.Last_IP, documents.*, images.File_Name, images.Mime_Type
                              FROM documents
                              LEFT JOIN images ON images.Document_ID = documents.Document_ID
                              LEFT JOIN users ON users.User_ID = documents.User_ID
                              LEFT JOIN persons ON users.Person_ID = persons.Person_ID
                              LEFT JOIN person_addresses ON person_addresses.Person_ID = persons.Person_ID
                              LEFT JOIN addresses ON addresses.Address_ID = person_addresses.Address_ID";

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

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Document_ID', // group starts from this column
                        "numberOfColumns"=>3, // group span to next 2 columns
                        "titleText"=>'Document 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"=>'User_ID', // group starts from this column
                        "numberOfColumns"=>7, // group span to next 2 columns
                        "titleText"=>'User Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'First_Name', // group starts from this column
                        "numberOfColumns"=>6, // group span to next 2 columns
                        "titleText"=>'Person Information' // caption of group header
                    ),
                    array(
                        "startColumnName"=>'Address1', // group starts from this column
                        "numberOfColumns"=>8, // group span to next 2 columns
                        "titleText"=>"User's Address" // caption of group header
                    )
                )
            )
        );

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

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #2
0
 public function index()
 {
     //echo $this->session->userdata('user_id');
     if ($this->session->userdata('user_name')) {
         $i_rule = $this->session->userdata('user_cizacl_role_id');
         if ($this->cizacl->check_isAllowed($i_rule, 'income', 'index')) {
             // master grid
             $grid = new jqgrid();
             $opt["caption"] = $this->lang->line('factory');
             // following params will enable subgrid -- by default first column (PK) of parent is passed as param 'id'
             $opt["detail_grid_id"] = "list2";
             //$opt['width'] = 300;
             $opt['autowidth'] = true;
             $opt['height'] = "60";
             // extra params passed to detail grid, column name comma separated
             //$opt["subgridparams"] = "client_id,gender,company";
             $opt["subgridparams"] = "factory_id,factory_code,factory_name";
             #set Grid Option
             $grid->set_options($opt);
             $grid->select_command = "SELECT * FROM transport_factory WHERE factory_status =1";
             #Select table
             $grid->table = "transport_factory";
             /*Define Column*/
             #ID
             $col = array();
             $col["title"] = $this->lang->line('id');
             // caption of column
             $col["name"] = "factory_id";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "10";
             $col["editable"] = false;
             $col['hidden'] = true;
             $cols[] = $col;
             #Factory code
             $col = array();
             $col['title'] = $this->lang->line('factory_code');
             $col['name'] = "factory_code";
             $col["editable"] = false;
             $cols[] = $col;
             $col = array();
             $col['title'] = $this->lang->line('factory_name');
             $col['name'] = "factory_name";
             //$col["width"] = "10";
             $col["editable"] = false;
             $cols[] = $col;
             $grid->set_columns($cols);
             $grid->set_actions(array("add" => false, "edit" => false, "delete" => false, "rowactions" => false, "autofilter" => false));
             //Display master
             $out_master = $grid->render("list1");
             // detail grid
             $grid = new jqgrid();
             $opt = array();
             $opt["sortname"] = 'income_date';
             // by default sort grid by this field
             $opt["sortorder"] = "desc";
             // ASC or DESC
             $opt["height"] = 300;
             // autofit height of subgrid
             $opt["rowNum"] = 10;
             // by default 20
             $opt['rowList'] = array(10, 20, 30, 100, 1000);
             $opt["autowidth"] = true;
             $opt["caption"] = $this->lang->line('income_invoice');
             // caption of grid
             //$opt["multiselect"] = true; // allow you to multi-select through checkboxes
             //footer
             $opt["footerrow"] = true;
             $opt["reloadedit"] = true;
             // Check if master record is selected before detail addition
             $opt["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('Please select master record first'); return false; } }";
             $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
             $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
             $opt["add_options"]["topinfo"] = $this->lang->line('income_title_from_add');
             $opt["add_options"]["bottominfo"] = $this->lang->line('remark_numberic');
             $opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#ref_number").focus(); }';
             $opt["form"]["position"] = "left";
             $opt["form"]["nav"] = true;
             $opt["multiselect"] = false;
             $opt["rownumbers"] = true;
             // disable all dialogs except edit
             $grid->navgrid["param"]["edit"] = false;
             $grid->navgrid["param"]["add"] = false;
             $grid->navgrid["param"]["del"] = false;
             $grid->navgrid["param"]["search"] = false;
             $grid->navgrid["param"]["refresh"] = true;
             // enable inline editing buttons
             $grid->set_actions(array("inline" => true, "rowactions" => true));
             // Properties Grids
             $grid->set_options($opt);
             $grid->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'income', 'add'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'income', 'edit'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'income', 'delete'), "rowactions" => true, "export" => false, "autofilter" => true, "search" => "advance"));
             $id = intval($_GET["rowid"]);
             $factory_code = $_GET["factory_code"];
             $company = $_GET["factory_name"];
             $cid = intval($_GET["factory_id"]);
             // for non-int fields as PK
             // $id = (empty($_GET["rowid"])?0:$_GET["rowid"]);
             // and use in sql for filteration
             //$grid->select_command = "SELECT id,client_id,invdate,amount,tax,total,'$company' as 'company' FROM invheader WHERE client_id = $cid";
             //$grid->select_command = "SELECT id,income_date,factory_id,ref_number,total_amount,note FROM `income` WHERE factory_id=$cid";
             $grid->select_command = "SELECT id,income_date,factory_id,ref_number,income_details,total_amount,note,(SELECT SUM(total_amount)FROM\tincome WHERE factory_id = {$cid}\t) AS table_total FROM\t`income`WHERE\tfactory_id = {$cid}";
             // this db table will be used for add,edit,delete
             //Select database
             $grid->table = "income";
             /*Define column*/
             #id
             $col = array();
             $col["title"] = $this->lang->line('id');
             // caption of column
             $col["name"] = "id";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "30";
             $col['hidden'] = true;
             $cols2[] = $col;
             #DATE
             $col = array();
             $col["title"] = $this->lang->line('date');
             $col["name"] = "income_date";
             $col["width"] = "50";
             $col["editable"] = true;
             // this column is editable
             $col["editoptions"] = array("size" => 20);
             // with default display of textbox with size 20
             $col["editrules"] = array("required" => true);
             // and is required
             # format as date
             $col["formatter"] = "date";
             # opts array can have these options: http://api.jqueryui.com/datepicker/
             $col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
             $cols2[] = $col;
             # Reference Number
             $col = array();
             $col["title"] = $this->lang->line('reference_number');
             // caption of column
             $col["name"] = "ref_number";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "30";
             $col["editable"] = true;
             $col['hidden'] = true;
             $cols2[] = $col;
             # Detail
             $col = array();
             $col["title"] = $this->lang->line('desc');
             // caption of column
             $col["name"] = "income_details";
             // field name, must be exactly same as with SQL prefix or db field
             $col["editrules"] = array("required" => true);
             // and is required
             $col["width"] = "60";
             $col["editable"] = true;
             $col['edittype'] = "textarea";
             $col['editoptions'] = array("rows" => '2', "cols" => '50', "defaultValue" => ' ');
             $col["formatter"] = "autocomplete";
             // autocomplete
             $col["formatoptions"] = array("sql" => "SELECT DISTINCT income_details as k, income_details as v FROM income", "search_on" => "income_details", "update_field" => "income_details");
             $cols2[] = $col;
             #total Amount
             $col = array();
             $col["title"] = $this->lang->line('amount');
             $col["name"] = "total_amount";
             $col["width"] = "40";
             $col['align'] = "right";
             $col['formatter'] = "currency";
             $col["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
             $col["editable"] = true;
             // this column is editable
             $col["editoptions"] = array("size" => 20);
             // with default display of textbox with size 20
             $col["editrules"] = array("required" => true, "number" => true);
             // and is required
             $cols2[] = $col;
             # Remark
             $col = array();
             $col["title"] = $this->lang->line('note');
             // caption of column
             $col["name"] = "note";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "40";
             $col["editable"] = true;
             $col['edittype'] = "textarea";
             $col['editoptions'] = array("rows" => '2', "cols" => '20', "defaultValue" => ' ');
             $col["formatter"] = "autocomplete";
             // autocomplete
             $col["formatoptions"] = array("sql" => "SELECT DISTINCT note as k, note as v FROM income", "search_on" => "note", "update_field" => "note");
             $cols2[] = $col;
             // virtual column for grand total
             $col = array();
             $col["title"] = "table_total";
             $col["name"] = "table_total";
             $col["width"] = "100";
             $col["hidden"] = true;
             $cols2[] = $col;
             // virtual column for running total
             $col = array();
             $col["title"] = "running_total";
             $col["name"] = "running_total";
             $col["width"] = "100";
             $col["hidden"] = true;
             $cols[] = $col;
             $grid->set_columns($cols2);
             $e["js_on_load_complete"] = "grid2_onload";
             $e["on_insert"] = array("add_client", null, true);
             $grid->set_events($e);
             function add_client(&$data)
             {
                 $id = intval($_GET["rowid"]);
                 $data["params"]["factory_id"] = $id;
             }
             // generate grid output, with unique grid name as 'list1'
             $out_detail = $grid->render("list2");
             // Head Title
             $h2_title = $this->lang->line('income');
             $js_script = $this->income_model->income_fect_assoc($data);
             // Used JS Script
             //$id2 = intval($_GET["jqgrid_page"]);
             $id3 = intval($_GET['jqgrid_page']);
             //$data["params"]["factory_id"] = $id2;
             $js_script = $id3;
             //display
             $this->_example_output((object) array('output' => '', 'out_detail' => $out_detail, 'out_master' => $out_master, 'js_files' => array(), 'css_files' => array(), 'js_script' => $js_script, 'h2_title' => $h2_title));
         } else {
             $this->_example_output();
         }
         //end if
     } else {
         redirect('login', 'refresh');
     }
 }
Пример #3
0
 public function index()
 {
     if ($this->session->userdata('user_name')) {
         $g = new jqgrid();
         $dispyPrice = $this->price->dispalyPrice();
         $titke_cubic = $this->price->header_cubic();
         $row_distance = $this->price->row_distance();
         $i = 0;
         foreach ($row_distance as $key => $val) {
             // $i = $val['distance_id'];
             foreach ($titke_cubic as $row) {
                 $data[$i]["id"] = $i;
                 $data[$i]["distacne"] = $dispyPrice[$i]['distance'];
                 $data[$i]['cubic'][$row->cubic_id] = 2 + $i;
                 //$dispyPrice[$i][$row->cubic_id];
                 $data[$i]["pricelist_id"] = $dispyPrice[$row->id];
             }
             $i = $val['distance_id'];
         }
         $g->table = $data;
         // ห$g->table = $pricelist;
         $col = array();
         $col["title"] = "id";
         // caption of column
         $col["name"] = "id";
         $col["width"] = "250";
         $col["sorttype"] = int;
         $col['editable'] = true;
         $col['hidden'] = true;
         $cols[] = $col;
         $col = array();
         $col["title"] = "pricelist_id";
         // caption of column
         $col["name"] = "pricelist_id";
         $col["width"] = "250";
         $col["sorttype"] = int;
         $col['editable'] = true;
         #$col['hidden'] = true;
         //$cols[] = $col;
         $col = array();
         $col["title"] = "Cubic /<br/> Distance";
         // caption of column
         $col["name"] = "distacne";
         $col["width"] = "350";
         $cols[] = $col;
         foreach ($titke_cubic as $row) {
             $col = array();
             $col['title'] = "{$row->cubic_value}";
             $col['name'] = "cubic[{$row->cubic_id}]";
             $col['editable'] = true;
             $col['search'] = false;
             $cols[] = $col;
         }
         $g->set_columns($cols);
         $e["js_on_select_row"] = "do_onselect";
         $e["on_update"] = array("do_update", null, true);
         $e["on_data_display"] = array("filter_display", null, true);
         $g->set_events($e);
         function filter_display($data)
         {
             /*
             These comments are just to show the input param format 
             Array 
             ( 
             [params] => Array 
             ( 
             [0] => Array 
             ( 
             [client_id] => 1 
             [name] => Client 1 
             [gender] => My custom malea 
             [company] => My custom Client 1 Company 1 
             ) 
             
             [1] => Array 
             ( 
             [client_id] => 2 
             [name] => Client 2 
             [gender] => male 
             [company] => Client 2 Com2pany 11 
             ) 
             
             ....... 
             */
             foreach ($data["params"] as &$d) {
                 foreach ($d as $k => $v) {
                     $d[$k] = strtoupper($d[$k]);
                 }
             }
         }
         function do_update(&$data)
         {
             //  $obj = &get_instance();
             print_r($data);
             $id = intval($_REQUEST["id"]);
         }
         $g->set_actions(array("add" => false, "edit" => true, "bulkedit" => true, "delete" => true, "rowactions" => true, "autofilter" => true, "search" => "simple"));
         $opt['caption'] = "d";
         $opt["sortname"] = 'id';
         // by default sort grid by this field
         $opt["sortorder"] = "asc";
         // ASC or DESC
         $opt['rowNum'] = 30;
         $opt["autowidth"] = true;
         $opt["cellEdit"] = true;
         $g->set_options($opt);
         //Display
         $pricetable = $g->render("list1");
         $this->_example_output((object) array('output' => '', 'out' => $out, 'dispyPrice' => $dispyPrice, 'list_row' => $num_row, 'pricelist' => $pricelist, 'pricetable' => $pricetable));
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Пример #4
0
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $noteId = intval($_POST["id"]);
            $note = Notes::model()->findByPk($noteId);

            if ($note) {
                $note->Comment = $_POST["Comment"] ? $_POST["Comment"] : null;
                $note->Created = $_POST["Created"] ? $_POST["Created"] : null;
                if ($note->validate()) {
                    $note->save();
                    echo "note\n";
                }
            }

            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $noteId = intval($_POST["id"]);
            $note = Notes::model()->findByPk($noteId);
            if ($note) {
                $note->delete();
            }
            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"] = "Note ID"; // caption of column
        $col["name"] = "Note_ID";
        $col["dbname"] = "notes.Note_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"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Document ID"; // caption of column
        $col["name"] = "Document_ID";
        $col["dbname"] = "notes.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"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "User ID"; // caption of column
        $col["name"] = "User_ID";
        $col["dbname"] = "notes.User_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"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Company ID"; // caption of column
        $col["name"] = "Company_ID";
        $col["dbname"] = "notes.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"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client ID"; // caption of column
        $col["name"] = "Client_ID";
        $col["dbname"] = "notes.Client_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"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Comment"; // caption of column
        $col["name"] = "Comment";
        $col["dbname"] = "notes.Comment"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Created"; // caption of column
        $col["name"] = "Created";
        $col["dbname"] = "notes.Created"; // 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"] = "Notes";
        // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'notes.Note_ID';
        $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 notes.*
                              FROM notes";

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

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Note_ID', // group starts from this column
                        "numberOfColumns"=>7, // group span to next 2 columns
                        "titleText"=>'Note Information' // caption of group header
                    ),
                )
            )
        );

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

        $this->render('index',array(
            'out'=>$out,
        ));
    }
Пример #5
0
 public function index()
 {
     //check login
     if ($this->session->userdata('user_name')) {
         $i_rule = $this->session->userdata('user_cizacl_role_id');
         $g = new jqgrid();
         $col = array();
         $col["title"] = "Id";
         // caption of column
         $col["name"] = "tax_id";
         $col["width"] = "10";
         /*$col["fixed"] = true;*/
         $col["search"] = false;
         $col["editable"] = false;
         $col["hidden"] = true;
         $cols[] = $col;
         #tax date
         $col = array();
         $col['title'] = $this->lang->line('date');
         $col['name'] = "tax_date";
         $col["width"] = "170";
         $col["editable"] = true;
         // this column is editable
         $col["editoptions"] = array("size" => 20, "defaultValue" => date("d-m-Y"));
         // with default display of textbox with size 20
         $col["editrules"] = array("required" => true);
         // and is required
         $col["formatter"] = "date";
         // format as date
         $col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
         $cols[] = $col;
         #ref_number
         $col = array();
         $col['title'] = $this->lang->line('ref_no');
         $col['name'] = "ref_number";
         $col["editable"] = true;
         // this column is editable
         $cols[] = $col;
         #tax Datail
         $col = array();
         $col['title'] = $this->lang->line('tax_detail');
         $col['name'] = "tax_details";
         $col["width"] = "170";
         $col["editable"] = true;
         // this column is editable
         $col['edittype'] = "textarea";
         $col["editoptions"] = array("rows" => "2", "cols" => "20");
         $col["editrules"] = array("required" => true);
         $col["formatter"] = "autocomplete";
         // autocomplete
         $col["formatoptions"] = array("sql" => "SELECT DISTINCT tax_details as k, tax_details as v FROM taxbuy", "search_on" => "tax_details", "update_field" => "tax_details");
         $cols[] = $col;
         #Price
         $col = array();
         $col['title'] = $this->lang->line('total_price');
         $col['name'] = "total_price";
         $col["editable"] = true;
         $col["editrules"] = array("number" => true, "required" => true);
         $col["editoptions"] = array("onblur" => "update_vat()");
         $col["align"] = "right";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $col["search"] = false;
         $cols[] = $col;
         #vat
         $col = array();
         $col['title'] = $this->lang->line('vat');
         $col['name'] = "total_vat";
         $col["editable"] = true;
         $col["editrules"] = array("number" => true, "required" => true);
         #$col["editoptions"] = array("onblur" => "update_vat()");
         $col["formatter"] = "number";
         $col["align"] = "right";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $col["search"] = false;
         $cols[] = $col;
         #Total
         $col = array();
         $col['title'] = $this->lang->line('total_amount');
         $col["align"] = "right";
         $col['name'] = "total_amount";
         $col["editrules"] = array("number" => true, "required" => true);
         $col["editable"] = true;
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $col["search"] = false;
         $cols[] = $col;
         #Note
         $col = array();
         $col["title"] = $this->lang->line('remark');
         $col["name"] = "note";
         $col["width"] = "150";
         $col['editable'] = true;
         $col["edittype"] = "textarea";
         $col["editoptions"] = array("rows" => "2", "cols" => "20");
         $cols[] = $col;
         //$g->set_options($opt);
         $e["js_on_load_complete"] = "grid1_onload";
         $g->set_events($e);
         //Use Table
         $g->table = "taxbuy";
         // pass the cooked columns to grid
         $g->set_columns($cols);
         $opt["caption"] = $this->lang->line('buytax_list');
         $opt["sortname"] = 'tax_id';
         $opt["sortorder"] = "desc";
         $opt['rowNum'] = 10;
         $opt['rowList'] = array(10, 20, 30, 100);
         $opt["autowidth"] = true;
         $opt["footerrow"] = true;
         $opt["reloadedit"] = true;
         $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '400');
         $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '400');
         $opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#ref_number").focus(); }';
         $opt["edit_options"]["afterShowForm"] = 'function(formid) { jQuery("#ref_number").focus(); }';
         $g->set_options($opt);
         $g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'buytax', 'add_buytax'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'buytax', 'edit_buytax'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'buytax', 'del_buytax'), "view" => false, "rowactions" => false, "autofilter" => true, "search" => "advance", "inlineadd" => false, "showhidecolumns" => false));
         // render grid and get html/js output
         $out_index = $g->render("list1");
         $h2_title = $this->lang->line('buytax');
         //display
         $this->_example_output((object) array('output' => '', 'out' => $out_index, 'h2_title' => $h2_title, 'js_files' => array(), 'css_files' => array()));
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Пример #6
0
// with default display of textbox with size 20
$col["editrules"] = array("required" => true);
// and is required
$cols[] = $col;
$col = array();
$col["title"] = "Amount";
$col["name"] = "amount";
$col["width"] = "50";
$col["editable"] = true;
// this column is editable
$col["editoptions"] = array("size" => 20);
// with default display of textbox with size 20
$col["editrules"] = array("required" => true);
// and is required
$cols[] = $col;
$grid->set_columns($cols);
$e["on_insert"] = array("add_client", null, true);
$grid->set_events($e);
function add_client(&$data)
{
    $id = intval($_GET["rowid"]);
    $data["params"]["client_id"] = $id;
}
// generate grid output, with unique grid name as 'list1'
$out_detail = $grid->render("list2");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
	<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/themes/start/jquery-ui.custom.css"></link>	
	<link rel="stylesheet" type="text/css" media="screen" href="../../lib/js/jqgrid/css/ui.jqgrid.css"></link>	
Пример #7
0
 public function pregledRezervacije($id, $ime)
 {
     $col = array();
     $col["title"] = "Datum";
     $col["name"] = "reservation_week";
     $col["width"] = "20";
     $cols[] = $col;
     $col = array();
     $col["title"] = "Dvorana";
     $col["name"] = "reservation_day";
     $col["width"] = "10";
     $cols[] = $col;
     $col = array();
     $col["title"] = "Termin";
     $col["name"] = "reservation_time";
     $col["width"] = "20";
     $cols[] = $col;
     $col = array();
     $col["title"] = "Poveznica";
     $col["name"] = "event_name";
     $col["width"] = "20";
     $col["editable"] = true;
     $col["summaryType"] = "count";
     $col["edittype"] = "checkbox";
     $col["editoptions"] = array("value" => $ime . ": ");
     $cols[] = $col;
     $g = new jqgrid();
     // $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
     $grid["rowNum"] = 20;
     // by default 20
     $grid["sortname"] = 'reservation_day';
     // by default sort grid by this field
     $grid["sortorder"] = "desc";
     // ASC or DESC
     $grid["caption"] = "Vase rezervacije dvorana; Poveznice za kolegij -" . $ime;
     //$grid["autowidth"] = true; // expand grid to screen width
     $grid["width"] = "850";
     $grid["height"] = "550";
     $grid["multiselect"] = true;
     // allow you to multi-select through checkboxes
     $grid["hiddengrid"] = true;
     $grid["grouping"] = true;
     //
     $grid["groupingView"] = array();
     $grid["groupingView"]["groupField"] = array("reservation_week");
     // specify column name to group listing
     $grid["groupingView"]["groupColumnShow"] = array(true);
     // either show grouped column in list or not (default: true)
     //$grid["groupingView"]["groupText"] = array("<b>{0} - {1} Item(s)</b>"); // {0} is grouped value, {1} is count in group
     $grid["groupingView"]["groupOrder"] = array("asc");
     // show group in asc or desc order
     $grid["groupingView"]["groupDataSorted"] = array(true);
     // show sorted data within group
     $grid["groupingView"]["groupSummary"] = array(true);
     // work with summaryType, summaryTpl, see column: $col["name"] = "total";
     $grid["groupingView"]["groupCollapse"] = false;
     // Turn true to show group collapse (default: false)
     $grid["groupingView"]["showSummaryOnHide"] = true;
     // show summary row even if group collapsed (hide)
     // export XLS file
     // export to excel parameters
     $grid["export"] = array("format" => "xlsx", "filename" => "my-file", "sheetname" => "test");
     // RTL support
     // $grid["direction"] = "rtl";
     $grid["cellEdit"] = true;
     // inline cell editing, like spreadsheet
     $g->set_options($grid);
     $g->set_actions(array("add" => true, "edit" => true, "delete" => true, "rowactions" => true, "export" => true, "autofilter" => true, "search" => "advance"));
     // set database table for CRUD operations
     $g->table = 'phpmyreservation_reservations';
     $g->set_columns($cols);
     // subqueries are also supported now (v1.2)
     $g->select_command = "select * from (SELECT `reservation_week` , `reservation_day` , `reservation_time` , `event_name` \nFROM `phpmyreservation_reservations` \nWHERE `reservation_user_id`=" . $id . ") as o";
     $grid_id = "dvorane1";
     // render grid
     $out = $g->render($grid_id);
     $sql = "SELECT `reservation_week` , `reservation_day` , `reservation_time` , `event_name`  FROM `phpmyreservation_reservations` WHERE `reservation_user_id`=" . $id;
     return array('out' => $out, 'grid_id' => $grid_id, 'sql' => $sql, 'naziv' => $grid["caption"], 'cols' => $cols);
 }
Пример #8
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $paymentId = intval($_POST["id"]);
            $payment = Payments::model()->with('vendor')->findByPk($paymentId);

            if ($payment) {
                $vendor = $payment->vendor;
                $bank_account = $payment->bank_account;
                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";
                        }
                    }
                }

                if ($bank_account) {
                    $bank_account->Account_Number = $_POST["Account_Number"];
                    $bank_account->Account_Name = $_POST["Account_Name"];
                    $bank_account->Bank_Name = $_POST["Bank_Name"];
                    $bank_account->Bank_Routing = $_POST["Bank_Routing"];
                    $bank_account->Bank_SWIFT = $_POST["Bank_SWIFT"];
                    if ($bank_account->validate()) {
                        $bank_account->save();
                        echo "bank account\n";
                    }
                }

                $payment->Payment_Check_Date = $_POST["Payment_Check_Date"] ? $_POST["Payment_Check_Date"] : null;
                $payment->Payment_Check_Number = $_POST["Payment_Check_Number"] ? $_POST["Payment_Check_Number"] : null;
                $payment->Payment_Amount = $_POST["Payment_Amount"] ? $_POST["Payment_Amount"] : null;
                if ($payment->validate()) {
                    $payment->save();
                    echo "payment\n";
                }
            }

            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $paymentId = intval($_POST["id"]);
            $payment = Payments::model()->findByPk($paymentId);
            if ($payment) {
                Payments::deletePayment($paymentId);
            }
            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"] = "Payment ID"; // caption of column
        $col["name"] = "Payment_ID";
        $col["dbname"] = "payments.Payment_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"] = "payments.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;

        $col = array();
        $col["title"] = "Payment Check Date"; // caption of column
        $col["name"] = "Payment_Check_Date";
        $col["dbname"] = "payments.Payment_Check_Date"; // 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["formatter"] = "date";
        $col["formatoptions"] = array("srcformat"=>'Y-m-d',"newformat"=>'Y-m-d');
        $cols[] = $col;

        $col = array();
        $col["title"] = "Payment Check Number"; // caption of column
        $col["name"] = "Payment_Check_Number";
        $col["dbname"] = "payments.Payment_Check_Number"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Payment Amount"; // caption of column
        $col["name"] = "Payment_Amount";
        $col["dbname"] = "payments.Payment_Amount"; // 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"] = "Account Number"; // caption of column
        $col["name"] = "Account_Number";
        $col["dbname"] = "bank_acct_nums.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"] = "Account Name"; // caption of column
        $col["name"] = "Account_Name";
        $col["dbname"] = "bank_acct_nums.Account_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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Bank Name"; // caption of column
        $col["name"] = "Bank_Name";
        $col["dbname"] = "bank_acct_nums.Bank_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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Bank Routing"; // caption of column
        $col["name"] = "Bank_Routing";
        $col["dbname"] = "bank_acct_nums.Bank_Routing"; // 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"] = "Bank SWIFT"; // caption of column
        $col["name"] = "Bank_SWIFT";
        $col["dbname"] = "bank_acct_nums.Bank_SWIFT"; // 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"] = "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"] = "Payments";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$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.*,
                                       payments.*, bank_acct_nums.Account_Number, bank_acct_nums.Account_Name,
                                       bank_acct_nums.Bank_Name, bank_acct_nums.Bank_Routing, bank_acct_nums.Bank_SWIFT,
                                       images.File_Name, images.Mime_Type
                              FROM payments
                              LEFT JOIN documents ON documents.Document_ID = payments.Document_ID
                              LEFT JOIN images ON images.Document_ID = documents.Document_ID
                              LEFT JOIN bank_acct_nums ON bank_acct_nums.Account_Num_ID = payments.Account_Num_ID
                              LEFT JOIN vendors ON payments.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 = "payments";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Payment_ID', // group starts from this column
                        "numberOfColumns"=>10, // group span to next 2 columns
                        "titleText"=>'Payment 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("payments");

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #9
0
 public function index()
 {
     if ($this->session->userdata('user_name')) {
         $i_rule = $this->session->userdata('user_cizacl_role_id');
         $this->load->model('income_model', 'dropdrown');
         $this->load->model('dropdown_model', 'cus_drop');
         date_default_timezone_set('Asia/Bangkok');
         $g = new jqgrid();
         $col = array();
         $col["title"] = "Id";
         // caption of column
         $col["name"] = "id";
         $col["width"] = "10";
         $col["fixed"] = true;
         $col["search"] = false;
         $col["editable"] = false;
         $col["export"] = false;
         $col["hidden"] = true;
         $cols[] = $col;
         #Date
         $col = array();
         $col["title"] = $this->lang->line('date');
         $col["name"] = "order_date";
         $col["fixed"] = true;
         $col["width"] = "150";
         $col["editable"] = true;
         // this column is editable
         $col["editoptions"] = array("size" => 20, "defaultValue" => date("d-m-Y H:i:s"));
         // with default display of textbox with size 20
         $col["editrules"] = array("required" => true);
         // and is required
         $col["formatter"] = "datetime";
         // format as date
         $col["formatoptions"] = array("srcformat" => 'Y-m-d H:i:s', "newformat" => 'd-m-Y H:i:s', "opts" => array("changeYear" => false, "timeFormat" => "hh:mm tt"));
         $col["search"] = true;
         $cols[] = $col;
         #DP Number
         $col = array();
         $col["title"] = $this->lang->line('dp_number');
         // caption of column
         $col["name"] = "dp_number";
         $col["fixed"] = true;
         $col["width"] = "100";
         $col["search"] = true;
         $col["editrules"] = array("required" => true);
         $col['editoptions'] = array("defaultValue" => "", "min" => "1", "max" => "10", "maxlength" => "10");
         $col["editable"] = true;
         $cols[] = $col;
         #Customer
         $col = array();
         $col["title"] = "customer_id";
         $col["name"] = "customer_id";
         $col["width"] = "10";
         $col["editable"] = true;
         $col["export"] = false;
         $col["hidden"] = true;
         $cols[] = $col;
         #Customer name
         $col = array();
         $col["title"] = $this->lang->line('customer');
         $col["name"] = "cid";
         $col["dbname"] = "cus.customers_name";
         // this is required as we need to search in name field, not id
         $col["fixed"] = true;
         $col["width"] = "200";
         $col["align"] = "left";
         $col["editrules"] = array("required" => true);
         $col["search"] = true;
         $col["editable"] = true;
         $col["formatter"] = "autocomplete";
         // autocomplete
         $col["formatoptions"] = array("sql" => "SELECT * FROM (SELECT customer_id as k, customers_name  as v FROM transport_customers where customer_type_id=1 GROUP BY customers_name) o", "search_on" => "v", "update_field" => "customer_id");
         $cols[] = $col;
         #factory
         $col = array();
         $col["title"] = $this->lang->line('factory');
         $col["name"] = "factory_id";
         $col["dbname"] = "fac.factory_code";
         // this is required as we need to search in name field, not id
         $col["fixed"] = true;
         $col["width"] = "100";
         $col["align"] = "left";
         $col["search"] = true;
         $col["editable"] = true;
         $col["editrules"] = array("required" => true);
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         //$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
         $str = $this->dropdrown->get_factory_dropdown();
         $col["editoptions"] = array("value" => $str);
         $col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ \$('select[name=factory_id]').select2({width:'80%', dropdownCssClass: 'ui-widget ui-jqdialog'}); },200); }";
         $col["formatter"] = "select";
         // display label, not value
         $cols[] = $col;
         #Real Distance
         $col = array();
         $col['title'] = $this->lang->line('real_distance');
         $col['name'] = "real_distance";
         $col["fixed"] = true;
         $col['align'] = "center";
         $col['width'] = "65";
         $col["search"] = false;
         $col["editrules"] = array("required" => true, "number" => true);
         $col["editable"] = true;
         // this column is editable
         // $col["editoptions"] = array("defaultValue" => 1);
         $col["editoptions"] = array("defaultValue" => 1, "onchange" => array("sql" => "SELECT DISTINCT distance_id AS k,distance_code AS v FROM distancecode\nWHERE range_min <= '{real_distance}'\tAND range_max >='{real_distance}' ", "update_field" => "distance_id"));
         $cols[] = $col;
         #dis Distance_code
         $col = array();
         $col['title'] = $this->lang->line('distance_code');
         $col['name'] = "distance_id";
         $col['dbname'] = "dis.distance_code";
         $col["fixed"] = true;
         $col['width'] = "80";
         $col["search"] = false;
         $col['align'] = "center";
         $col["editable"] = true;
         $col["editrules"] = array("required" => true);
         $col["edittype"] = "select";
         // render as select
         $str = $this->cus_drop->get_distancecode_dropdown();
         $col["editoptions"] = array("value" => $str);
         #$col["formatter"] = "select"; // display label, not value
         // initially load 'note' of that client_id
         $col["editoptions"]["onload"]["sql"] = "SELECT DISTINCT distance_id AS k,distance_code AS v FROM distancecode\nWHERE range_min <= '{real_distance}'\tAND range_max >='{real_distance}' ";
         $col["formatter"] = "select";
         // display label, not value
         $col["stype"] = "select";
         // enable dropdown search
         $col["searchoptions"] = array("value" => ":;" . $str);
         $cols[] = $col;
         /*Cubic*/
         $col = array();
         $col['title'] = $this->lang->line('cubic_value');
         $col["name"] = "cubic_id";
         $col["dbname"] = "orders.cubic_id";
         // this is required as we need to search in name field, not id
         $col['width'] = "80";
         $col["fixed"] = true;
         $col["align"] = "center";
         $col["search"] = false;
         $col["editable"] = true;
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         $str = $g->get_dropdown_values("select distinct cubic_id as k, cubic_value as v from transport_cubiccode where cubic_status=1");
         //$str = $this->cus_drop->get_cubiccode_dropdown();
         $col["editoptions"] = array("value" => ":;" . $str);
         $col["editoptions"]["dataInit"] = "function(){ setTimeout(function(){ \$('select[name=cubic_id]').select2({width:'80%', dropdownCssClass: 'ui-widget ui-jqdialog'}); },200); }";
         $cols[] = $col;
         #price
         $col = array();
         $col['title'] = $this->lang->line('price');
         $col['name'] = "price";
         $col['align'] = "right";
         $col["fixed"] = true;
         $col['width'] = "80";
         //$col["editrules"] = array("number" => true);
         $col['editoptions'] = array("defaultValue" => "0", "readonly" => true);
         #$col['hidden'] = true;
         $col["show"] = array("list" => true, "add" => false, "edit" => false, "view" => true);
         $col['editable'] = true;
         $col['search'] = false;
         $cols[] = $col;
         /*End Cubic*/
         #car
         $col = array();
         $col["title"] = $this->lang->line('car_number');
         $col['name'] = "car_id";
         $col['dbname'] = "car.car_number";
         $col["fixed"] = true;
         $col['align'] = "center";
         $col['width'] = "85";
         $col['search'] = true;
         $col['editable'] = true;
         $col["editrules"] = array("required" => true);
         $col['edittype'] = "select";
         $str = $this->cus_drop->get_car_dropdown();
         $col["editoptions"] = array("value" => $str, "onchange" => array("sql" => "SELECT DISTINCT driver_id as k, driver_name as v  FROM driver WHERE car_id = '{car_id}'", "update_field" => "driver_id"));
         $col['formatter'] = "select";
         //$col["stype"] = "select"; // enable dropdown search
         //$col["searchoptions"] = array("car_id" => ":;".$str);
         $cols[] = $col;
         #Driver
         $col = array();
         $col["title"] = $this->lang->line('driver');
         $col['name'] = "driver_id";
         $col['dbname'] = "dri.driver_name";
         $col["fixed"] = true;
         $col['width'] = "150";
         $col['search'] = true;
         $col['editable'] = true;
         $col['edittype'] = "select";
         $col["editrules"] = array("required" => true);
         $str = $this->cus_drop->get_drivers_dropdown();
         $col['editoptions'] = array("value" => $str);
         $col['formatter'] = "select";
         $col["searchoptions"] = array("car_id" => ":;" . $str);
         $cols[] = $col;
         #OilUse
         $col = array();
         $col['title'] = $this->lang->line('use_oil');
         $col['name'] = "use_oil";
         $col['dbname'] = "orders.use_oil";
         $col["fixed"] = true;
         $col['align'] = "center";
         $col['width'] = "70";
         $col["editoptions"] = array("number" => true, "defaultValue" => '0');
         $col['editrules'] = array("number" => true);
         $col['formater'] = "number";
         $col['editable'] = true;
         $cols[] = $col;
         #Remark
         $col = array();
         $col['title'] = $this->lang->line('remark');
         $col['name'] = "remark";
         $col['dbname'] = "orders.remark";
         $col["fixed"] = true;
         $col['width'] = "120";
         $col["edittype"] = "textarea";
         $col["editoptions"] = array("rows" => 2, "cols" => 20);
         $col['editable'] = true;
         $cols[] = $col;
         /*Grid Option*/
         $opt["sortname"] = 'id';
         $opt["sortorder"] = "desc";
         $opt["caption"] = $this->lang->line('Order_Transportation');
         $opt['rowNum'] = 10;
         $opt['rowList'] = array(10, 20, 30);
         $opt['height'] = "360";
         $opt["autowidth"] = true;
         $opt["multiselect"] = true;
         $opt["scroll"] = true;
         $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#dp_number").focus();}';
         $opt["edit_options"]["afterShowForm"] = 'function(formid) { jQuery("#dp_number").focus();}';
         $opt["altRows"] = true;
         $opt["altclass"] = "myAltRowClass";
         $opt["form"]["position"] = "center";
         // or "all"
         $g->set_options($opt);
         $g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'add'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'edit'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'delete'), "rowactions" => false, "export" => true, "autofilter" => true, "search" => "advance"));
         $g->select_command = "SELECT\n\tid,\n\tdp_number,\n\torders.customer_id,\n    cus.customers_name AS cid,\n    orders.factory_id,\n\tfac.factory_code,\n\treal_distance,\n\torders.distance_id,\n\tdis.distance_code,\t\n    cubic.cubic_value as cubic_id,\n    orders.price AS price,\n\torders.use_oil,\n    orders.car_id,\n\tcar.car_number,\n\torders.driver_id,\n\tdri.driver_name,\n    order_date,\n    orders.delivery_datetime,\n    orders.remark\n\nFROM\n\t`orders` AS orders\nLEFT JOIN transport_factory AS fac ON (\n\torders.factory_id = fac.factory_id\n)\nLEFT JOIN transport_customers AS cus ON (\n\torders.customer_id = cus.customer_id\n)\nLEFT JOIN transport_cubiccode AS cubic ON (\n\torders.cubic_id = cubic.cubic_id\n)\nLEFT JOIN distancecode AS dis ON (\n\torders.distance_id = dis.distance_id\n)\nLEFT JOIN transport_cars AS car ON (\norders.car_id = car.car_id\n)\nLEFT JOIN driver AS dri ON (\n\torders.driver_id = dri.driver_id\n)";
         // this db table will be used for add,edit,delete
         $g->table = "orders";
         $e["on_insert"] = array("add_order", null, true);
         $e["on_after_insert"] = array("after_insert", null, true);
         $e["on_update"] = array("do_update", null, true);
         $e["on_data_display"] = array("filter_display", null, true);
         $g->set_events($e);
         function add_order(&$data)
         {
             //print_r($data);
             $obj =& get_instance();
             $obj->load->model("price_model", "pricelist");
             //$id = intval($_REQUEST["id"]);
             $factory_id = $data["params"]["factory_id"];
             $distance_id = $data["params"]["distance_id"];
             $cubid_id = $data["params"]["cubic_id"];
             $order_date = $data["params"]["order_date"];
             #get price
             $order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
             if ($order_price == null) {
                 $str = ob_get_clean();
                 $str = "ยังไม่มีการกำหนดราคาค่าขนส่ง";
                 phpgrid_error($str);
             }
             /*check DP NUmber*/
             $check_sql = "SELECT count(*) as c from orders where LOWER(`dp_number`) = '" . strtolower($data["params"]["dp_number"]) . "'";
             $rs = mysql_fetch_assoc(mysql_query($check_sql));
             if ($rs["c"] > 0) {
                 phpgrid_error("หมายเลข DP Number ซ้ำ");
             }
             /*End Check DP Number*/
             //$str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
             //mysql_query($str);
         }
         function do_update(&$data)
         {
             //print_r($data);
             $obj =& get_instance();
             $obj->load->model("price_model", "pricelist");
             $id = intval($_REQUEST["id"]);
             $factory_id = $data["params"]["factory_id"];
             $distance_id = $data["params"]["distance_id"];
             $cubid_id = $data["params"]["cubic_id"];
             $order_date = $data["params"]["order_date"];
             #get price
             $order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
             if ($order_price == null) {
                 $str = ob_get_clean();
                 $str = "ยังไม่มีการกำหนดราคาค่าขนส่ง";
                 phpgrid_error($str);
             } else {
                 $data["params"]["price"] = $order_price;
                 $str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
                 mysql_query($str);
             }
             //$str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
             //mysql_query($str);
         }
         function after_insert(&$data)
         {
             //print_r($data);
             $obj =& get_instance();
             $obj->load->model("price_model", "pricelist");
             $id = $data["id"];
             $factory_id = $data["params"]["factory_id"];
             $distance_id = $data["params"]["distance_id"];
             $cubid_id = $data["params"]["cubic_id"];
             $order_date = $data["params"]["order_date"];
             #get price
             $order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
             $str = "UPDATE orders SET price ='{$order_price}' \n                    WHERE id = {$data["id"]}";
             mysql_query($str);
         }
         function filter_display(&$data)
         {
             foreach ($data["params"] as &$d) {
                 foreach ($d as $k => $v) {
                     $d[$k] = strtoupper($d[$k]);
                 }
             }
         }
         // pass the cooked columns to grid
         $g->set_columns($cols);
         // generate grid output, with unique grid name as 'list1'
         $out = $g->render("list1");
         $iprice = $this->price->get_order_Price(2, 2, 2);
         $h2_title = $this->lang->line('order_car_truck');
         //display
         $this->_example_output((object) array('output' => "", 'out' => $out, 'h2_title' => $h2_title, 'iprice' => $iprice, 'js_files' => array(), 'css_files' => array()));
         //$this->_example_output();
     } else {
         redirect('login', 'refresh');
     }
     //end if
 }
Пример #10
0
 function getDataGrid($id)
 {
     $g = new jqgrid();
     $this->db = $this->cx->conectar();
     $type = 'gridoptions';
     $result = $this->db->Execute("SELECT b.nb_property_fld,b.nb_type_fld,a.nb_value_fld FROM nb_datagrid_tbl a , nb_config_frmwrk_tbl b WHERE  a.nb_config_frmwrk_id_fld = b.nb_config_frmwrk_id_fld and b.nb_config_type_fld='{$type}' and a.nb_id_page_fld = '{$id}'");
     while ($row = $result->FetchRow()) {
         $value = $row[2];
         if ($row[0] != 'table') {
             if ($row[1] == 'number') {
                 $value = (int) $value;
             }
             if ($row[1] == 'boolean') {
                 if ($value == 'true') {
                     $value = true;
                 } else {
                     $value = false;
                 }
             }
             $grid[$row[0]] = $value;
         } else {
             $g->table = $value;
         }
     }
     $this->campos = $this->db->Execute("Select distinct a.nb_column_fld from nb_datagridcol_tbl a where a.nb_id_page_fld = '{$id}'");
     $type = 'gridcoloptions';
     while ($camposDescribe = $this->campos->FetchRow()) {
         $result = $this->db->Execute("SELECT b.nb_property_fld,b.nb_type_fld,a.nb_value_fld FROM nb_datagridcol_tbl a , nb_config_frmwrk_tbl b WHERE  a.nb_config_frmwrk_id_fld = b.nb_config_frmwrk_id_fld and b.nb_config_type_fld='{$type}' and a.nb_id_page_fld = '{$id}' and a.nb_column_fld='{$camposDescribe['0']}'");
         $col = array();
         while ($row = $result->FetchRow()) {
             $value = $row[2];
             if ($row[1] == 'number') {
                 $value = (int) $value;
             }
             if ($row[1] == 'boolean') {
                 if ($value == 'true') {
                     $value = true;
                 } else {
                     $value = false;
                 }
             }
             $col[$row[0]] = $value;
         }
         $cols[] = $col;
     }
     $g->set_columns($cols);
     $g->set_options($grid);
     $g->set_actions(array("add" => false, "edit" => false, "delete" => false, "rowactions" => false, "search" => "advance", "export" => false, "autofilter" => true));
     return $g->render("list1");
 }
Пример #11
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $w9RevId = trim($_POST["id"]);
            $w9Rev = W9Revisions::model()->findByAttributes(array(
                'Revision_ID' => $w9RevId,
            ));
            $w9s = W9::model()->findByAttributes(array(
                'Revision_ID' => $w9RevId,
            ));
            if ($w9Rev && !$w9s) {
                $w9Rev->delete();
            }
            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"] = "Revision ID"; // caption of column
        $col["name"] = "Revision_ID";
        $col["dbname"] = "Revision_ID"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = true;
        $cols[] = $col;

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


        $g = new jqgrid();

        $grid["caption"] = "W9 Revisions";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'Revision_ID';
        $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"=>true, // 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   *
                              FROM w9_revisions";

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

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Revision_ID', // group starts from this column
                        "numberOfColumns"=>2, // group span to next 2 columns
                        "titleText"=>'W9 Revisions' // caption of group header
                    ),
                )
            )
        );

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

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #12
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $companyId = intval($_POST["id"]);
            $company = Companies::model()->with('client', 'adreses')->findByPk($companyId);
            if ($company) {
                if ($company->client) {
                    $client = $company->client;
                    $client->Client_Number = $_POST["Client_Number"];
                    $client->Client_Logo_Name = $_POST["Client_Logo_Name"];
                    $client->Client_Approval_Amount_1 = $_POST["Client_Approval_Amount_1"] ? $_POST["Client_Approval_Amount_1"] : null;
                    $client->Client_Approval_Amount_2 = $_POST["Client_Approval_Amount_2"] ? $_POST["Client_Approval_Amount_2"] : null;
                    if ($client->validate()) {
                        $client->save();
                        echo "client\n";
                    }
                }

                if ($company->adreses) {
                    $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 "address\n";
                        }
                    }
                }

                $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";
                }
            }
            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $companyId = intval($_POST["id"]);
            $company = Companies::model()->with('client', 'adreses')->findByPk($companyId);
            $documents = Documents::model()->findByAttributes(array(
                'Client_ID' => $company->client->Client_ID,
            ));

            if ($company && !$documents) {
                if ($company->client) {
                    $client = $company->client;

                    UsersToApprove::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    UsersClientList::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    UsersProjectList::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    BankAcctNums::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    Coa::model()->deleteAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    Vendors::model()->deleteAllByAttributes(array(
                        'Client_Client_ID' => $client->Client_ID,
                    ));

                    Vendors::model()->deleteAllByAttributes(array(
                        'Vendor_Client_ID' => $client->Client_ID,
                    ));

                    $w9s = W9::model()->findAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    if ($w9s) {
                        foreach ($w9s as $w9) {
                            W9::deleteW9($w9->W9_ID);
                        }
                    }

                    $projects = Projects::model()->findAllByAttributes(array(
                        'Client_ID' => $client->Client_ID,
                    ));

                    if ($projects) {
                        foreach ($projects as $project) {
                            PoFormatting::model()->deleteAllByAttributes(array(
                                'Project_ID' => $project->Project_ID,
                            ));
                            $project->delete();
                        }
                    }

                    $client->delete();
                }

                if ($company->adreses) {
                    $addresses = $company->adreses;
                    foreach ($addresses as $address) {
                        $address->delete();
                    }
                }

                CompanyAddresses::model()->deleteAllByAttributes(array(
                    'Company_ID' => $companyId,
                ));

                $company->delete();
            }
            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"] = "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"] = false;
        $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;

        // set columns
        $col = array();
        $col["title"] = "Client ID"; // caption of column
        $col["name"] = "Client_ID";
        $col["dbname"] = "clients.Client_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;

        $col = array();
        $col["title"] = "Client Number"; // caption of column
        $col["name"] = "Client_Number";
        $col["dbname"] = "clients.Client_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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client Logo Name"; // caption of column
        $col["name"] = "Client_Logo_Name";
        $col["dbname"] = "clients.Client_Logo_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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Client Approval Amount 1"; // caption of column
        $col["name"] = "Client_Approval_Amount_1";
        $col["dbname"] = "clients.Client_Approval_Amount_1"; // 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"] = "Client Approval Amount 2"; // caption of column
        $col["name"] = "Client_Approval_Amount_2";
        $col["dbname"] = "clients.Client_Approval_Amount_2"; // 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;

        // set columns
        $col = array();
        $col["title"] = "Address ID"; // caption of column
        $col["name"] = "Address_ID";
        $col["dbname"] = "addresses.Address_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;

        $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"] = "Clients";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$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  clients.Client_ID, clients.Client_Number, clients.Client_Logo_Name,
                                      companies.*, addresses.*, clients.Client_Approval_Amount_1,
                                      clients.Client_Approval_Amount_2
                              FROM clients
                              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 = "clients";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    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"=>'Client_ID', // group starts from this column
                        "numberOfColumns"=>5, // group span to next 2 columns
                        "titleText"=>'Client 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("Clients");

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #13
0
 public function index()
 {
     if ($this->session->userdata('user_name')) {
         $this->load->model('factory_model', 'factory');
         $factory = $this->factory->getFactory();
         if (isset($_REQUEST['submit'])) {
             //$startDate = '2014-10-01';
             // $endDate = '2014-10-31';
             $factory_id = $this->input->get_post('factory');
             $startDate = $this->input->post('startDate');
             $endDate = $this->input->post('endDate');
             $factory_name = $this->factory->getNamefactory($factory_id);
             /*0000-00-00*/
             $start_date = $this->conv_date->thai2engDate($startDate);
             $end_date = $this->conv_date->thai2engDate($endDate);
             $dispyPrice = $this->price->dispalyPrice($factory_id, $start_date, $end_date);
             $dispyPrice2 = $this->price->dispalyPrice($factory_id, $start_date, $end_date);
             $dataFilter = array('pricelist_factory' => $factory_id, 'select_startDate' => $startDate, 'select_endDate' => $endDate, 'selected_start_date' => $start_date, 'selected_end_date' => $end_date);
             $this->session->set_userdata($dataFilter);
             $_SESSION['factory'] = $factory_id;
             $_SESSION['startDate'] = $start_date;
             $_SESSION['endDate'] = $end_date;
         }
         // End if
         if ($this->session->userdata('pricelist_factory')) {
             $selected_factory_id = $this->session->userdata('pricelist_factory');
             $selected_startDate = $this->session->userdata('select_startDate');
             $selected_endDate = $this->session->userdata('select_endDate');
         }
         $head_title = "ตารางราคาเดินรถ {$factory_name} ระหว่าง {$startDate} ถึง {$endDate}";
         //Display Pricelist Detail
         $g = new jqgrid();
         //$dispyPrice = $this->price->dispalyPrice($factory_id,$startDate,$endDate);
         $titke_cubic = $this->price->header_cubic();
         $row_distance = $this->price->row_distance();
         $title_distance = $this->price->row_distanceName();
         //$i = 0;
         foreach ($row_distance as $key => $val) {
             $i = $val['distance_id'];
             foreach ($titke_cubic as $row) {
                 $data[$i]["id"] = $i;
                 $data[$i]["distacne"] = $title_distance[$i];
                 //$dispyPrice[$i]['distance'];
                 $data[$i]["cubic[{$row->cubic_id}]"] = $dispyPrice[$i][$row->cubic_id];
                 $data[$i]["factory_id"] = $selected_factory_id;
                 $data[$i]['start_date'] = $selected_startDate;
                 $data[$i]['end_date'] = $selected_endDate;
             }
             // $i = $val['distance_id'];
         }
         $g->table = $data;
         //$g->table = "pricelist";
         // ห$g->table = $pricelist;
         $col = array();
         $col["title"] = "id";
         // caption of column
         $col["name"] = "id";
         $col["width"] = "60";
         $col["sorttype"] = int;
         $col['editable'] = true;
         $col['hidden'] = true;
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('cubic_and_distance');
         // caption of column
         $col["name"] = "distacne";
         $col["width"] = "350";
         $col['editable'] = false;
         $cols[] = $col;
         $col = array();
         $col["title"] = "factory_id";
         // caption of column
         $col["name"] = "factory_id";
         $col["width"] = "350";
         $col['editable'] = true;
         $col["editrules"] = array("required" => true);
         $col['hidden'] = true;
         $cols[] = $col;
         $col = array();
         $col["title"] = "start_date";
         // caption of column
         $col["name"] = "start_date";
         $col["width"] = "350";
         $col['editable'] = true;
         $col["editrules"] = array("required" => true);
         $col['hidden'] = true;
         $cols[] = $col;
         $col = array();
         $col["title"] = "end_date";
         // caption of column
         $col["name"] = "end_date";
         $col['editable'] = true;
         $col["editrules"] = array("required" => true);
         $col['hidden'] = true;
         $col["width"] = "350";
         $cols[] = $col;
         foreach ($titke_cubic as $row) {
             $col = array();
             $col['title'] = "{$row->cubic_value}";
             $col['name'] = "cubic[{$row->cubic_id}]";
             $col['editable'] = true;
             $col["editrules"] = array("number" => true);
             $col["formatter"] = "number";
             $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
             $col['search'] = false;
             $cols[] = $col;
         }
         $g->set_columns($cols);
         $g->set_actions(array("add" => false, "edit" => true, "bulkedit" => false, "delete" => true, "rowactions" => false, "autofilter" => true, "search" => "simple"));
         $opt['caption'] = "{$head_title}";
         $opt["sortname"] = 'id';
         // by default sort grid by this field
         $opt["sortorder"] = "asc";
         // ASC or DESC
         $opt['rowNum'] = 30;
         $opt["autowidth"] = true;
         $opt["cellEdit"] = true;
         // excel visual params
         $opt["cellEdit"] = true;
         // inline cell editing, like spreadsheet
         $opt["rownumbers"] = true;
         $opt["rownumWidth"] = 30;
         $g->set_options($opt);
         //$e["on_insert"] = array("add_client", null, true);
         $e["on_update"] = array("update_prices", null, true);
         //$e["on_delete"] = array("delete_client", null, true);
         //$e["on_after_insert"] = array("after_insert", null, true); // return last inserted id for further working
         //$e["on_data_display"] = array("filter_display", null, true);
         $g->set_events($e);
         function update_prices(&$data)
         {
             global $_SESSION;
             /*
             These comments are just to show the input param format
             
             $data => Array
             (
             [client_id] => 2
             [params] => Array
             (
             [client_id] => 2
             [name] => Client 2
             [gender] => male
             [company] => Client 2 Company
             )
             
             )
             */
             /*
             Array
             (
             [id] => 1
             [params] => Array
             (
             [cubic] => Array
             (
             [3] => 50
             )
             
             [id] => 1
             )
             
             )
             */
             // ob_start();
             $str = ob_get_clean();
             $obj =& get_instance();
             $obj->load->model("price_model", "price");
             $data['params']['factory_id'] = $_SESSION['factory'];
             $data['params']['start_date'] = $_SESSION['startDate'];
             $data['params']['end_date'] = $_SESSION['endDate'];
             $price_id = $data['params']['id'];
             $price_data = $data['params']['cubic'];
             foreach ($price_data as $k => $v) {
                 $data['params']['cubic_id'] = $k;
                 $data['params']['price'] = $v;
             }
             $factory_id = $data['params']['factory_id'];
             $distance_id = $data['params']['id'];
             $cubic_id = $data['params']['cubic_id'];
             $price = $data['params']['price'];
             $start_date = $data['params']['start_date'];
             $end_date = $data['params']['end_date'];
             //$m = $obj->price->recursive($mm,$factory_id,$start_date,$end_date);
             $mm = $obj->price->check_price_id($factory_id, $distance_id, $cubic_id, $start_date, $end_date);
             if ($mm == 0) {
                 $str = ob_get_clean();
                 $str = "INSERT INTO `pricelist` (\n\t`factory_id`,\n\t`cubic_id`,\n\t`distance_id`,\n\t`price`,\n\t`start_date`,\n\t`end_date`\n)\nVALUES\n\t(\n\t\t'{$factory_id}',\n\t\t'{$cubic_id}',\n\t\t'{$distance_id}',\n\t\t'{$price}',\n\t\t'{$start_date}',\n\t\t'{$end_date}'\n\t)";
             } else {
                 $str = ob_get_clean();
                 $str = "UPDATE `pricelist` SET `price`='{$price}' WHERE (`id`='{$mm}')";
             }
             //$str = $obj->price->recursive_price($factory_id,$distance_id,$cubic_id,$price,$start_date,$end_date);
             mysql_query($str);
             print_r($data);
         }
         // End of function
         //Display
         $pricetable = $g->render("list1");
         $pricelist2 = $this->price->displayPrice2();
         $this->_example_output((object) array('output' => '', 'out' => $out, 'dispyPrice' => $dispyPrice, 'dispyPrice2' => $dispyPrice2, 'list_row' => $num_row, 'factory' => $factory, 'start_date' => $start_date, 'end_date' => $end_date, 'pricelist2' => $pricelist2, 'pricetable' => $pricetable));
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Пример #14
0
 public function index()
 {
     //check login
     if ($this->session->userdata('user_name')) {
         $i_rule = $this->session->userdata('user_cizacl_role_id');
         if ($this->cizacl->check_isAllowed($i_rule, 'income')) {
             $grid = new jqgrid();
             $opt["caption"] = $this->lang->line('factory');
             $opt["detail_grid_id"] = "list2";
             $opt["autowidth"] = true;
             // extra params passed to detail grid, column name comma separated
             //$opt["subgridparams"] = "factory_id,factory_code,factory_name";
             $opt["subgridparams"] = "factory_id,factory_code,factory_name";
             $opt["export"] = array("filename" => "my-file", "sheetname" => "test", "format" => "pdf");
             $opt["export"]["range"] = "filtered";
             $grid->set_options($opt);
             $grid->table = "transport_factory";
             $col = array();
             $col["title"] = $this->lang->line('id');
             // caption of column
             $col["name"] = "factory_id";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "10";
             $col['hidden'] = true;
             $col["editable"] = false;
             $cols[] = $col;
             $col = array();
             $col['title'] = $this->lang->line('factory_code');
             $col['name'] = "factory_code";
             $col["width"] = "35";
             $col["editable"] = false;
             $cols[] = $col;
             $col = array();
             $col['title'] = $this->lang->line('factory_name');
             $col['name'] = "factory_name";
             $col["editable"] = false;
             $cols[] = $col;
             $grid->set_columns($cols);
             $grid->set_actions(array("add" => false, "edit" => false, "delete" => false, "rowactions" => false, "autofilter" => true, "search" => "advance"));
             $out_master = $grid->render("list1");
             // detail grid
             $grid = new jqgrid();
             $opt = array();
             $opt["sortname"] = 'id';
             // by default sort grid by this field
             $opt["sortorder"] = "desc";
             // ASC or DESC
             $opt["height"] = 400;
             // autofit height of subgrid
             $opt["rowNum"] = 10;
             // by default 20
             $opt['rowList'] = array(10, 20, 30, 100);
             $opt["autowidth"] = true;
             $opt["caption"] = $this->lang->line('expense_list');
             $opt["multiselect"] = true;
             $opt['height'] = '350';
             //footer
             $opt["footerrow"] = true;
             $opt["reloadedit"] = true;
             $opt["export"] = array("filename" => "my-file", "sheetname" => "test", "format" => "pdf");
             // export to excel parameters
             $opt["export"]["range"] = "filtered";
             // Check if master record is selected before detail addition
             $opt["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('Please select master record first'); return false; } }";
             $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '320');
             $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '320');
             $opt["add_options"]["topinfo"] = "บันทึกรายการซ่อม";
             //$opt["add_options"]["bottominfo"] = "This text is dialog footer text";
             $opt["form"]["position"] = "left";
             $opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#ref_number").focus(); }';
             $grid->set_options($opt);
             $grid->set_actions(array("add" => true, "edit" => true, "delete" => true, "rowactions" => true, "export" => false, "autofilter" => true, "search" => "advance"));
             // $id = intval($_GET["rowid"]);
             //$factory_code = $_GET["factory_code"];
             //$company = $_GET["factory_name"];
             //$cid = intval($_GET["factory_id"]);
             if (!empty($_REQUEST)) {
                 $id = intval($_GET["rowid"]);
                 $factory_code = $_GET["factory_code"];
                 $company = $_GET["factory_name"];
                 $cid = intval($_GET["factory_id"]);
                 $this->session->set_userdata('facs_id', $cid);
             }
             $fac_id = $this->session->userdata('facs_id');
             // for non-int fields as PK
             // $id = (empty($_GET["rowid"])?0:$_GET["rowid"]);
             $grid->select_command = "SELECT\n\tid,\n\texpense_date,\n\tfactory_id,\n\texpense.car_id,\n\tcar_number,\n\tref_number,\n\texpense_details,\n\ttotal_amount,\n\texpense.note,\n\t(\n\t\tSELECT\n\t\t\tSUM(total_amount)\n\t\tFROM\n\t\t\texpense\n\t\tWHERE\n\t\t\tfactory_id = {$fac_id}\n\t) AS sumtotals\nFROM\n\t`expense`\nLEFT JOIN transport_cars ON(expense.car_id=transport_cars.car_id)\nWHERE\n\tfactory_id = {$fac_id} AND expense.car_id !=0";
             //$grid->table = "invheader";
             $grid->table = "expense";
             $col = array();
             $col["title"] = $this->lang->line('id');
             // caption of column
             $col["name"] = "id";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "30";
             $col['hidden'] = true;
             $cols2[] = $col;
             $col = array();
             $col["title"] = $this->lang->line('date');
             $col["name"] = "expense_date";
             $col["width"] = "20";
             $col["resizable"] = false;
             $col["editable"] = true;
             // this column is editable
             $col["editoptions"] = array("size" => 20, "defaultValue" => date('Y-m-d'));
             // with default display of textbox with size 20
             $col["editrules"] = array("required" => true);
             // and is required
             # format as date
             $col["formatter"] = "date";
             # opts array can have these options: http://api.jqueryui.com/datepicker/
             $col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
             $cols2[] = $col;
             //car
             $col = array();
             $col["title"] = $this->lang->line('car_number');
             $col["name"] = "car_id";
             $col["dbname"] = "transport_cars.car_number";
             // this is required as we need to search in name field, not id
             $col["width"] = "20";
             $col["align"] = "center";
             $col["search"] = true;
             $col["editable"] = true;
             $col["edittype"] = "select";
             // render as select
             # fetch data from database, with alias k for key, v for value
             //$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
             $str = $this->getdrop->grid_dropdown("SELECT distinct car_id AS k,car_number AS v FROM `transport_cars`");
             $col["editoptions"] = array("value" => $str);
             $col["formatter"] = "select";
             // display label, not value
             $cols2[] = $col;
             #ref_number
             /*
             $col = array();
             $col["title"] = $this->lang->line('reference_number'); // caption of column
             $col["name"] = "ref_number"; // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "30";
             $col["editable"] = true;
             $cols2[] = $col;
             */
             # Detail
             $col = array();
             $col["title"] = $this->lang->line('desc');
             // caption of column
             $col["name"] = "expense_details";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "70";
             $col['edittype'] = "textarea";
             $col['editoptions'] = array("rows" => '2', "cols" => '50');
             $col["editrules"] = array("required" => true);
             $col["editable"] = true;
             $col["formatter"] = "autocomplete";
             // autocomplete
             $col["formatoptions"] = array("sql" => "SELECT DISTINCT expense_details as k, expense_details as v FROM expense", "search_on" => "expense_details", "update_field" => "expense_details");
             $cols2[] = $col;
             # Total Amount
             $col = array();
             $col["title"] = $this->lang->line('amount');
             $col["name"] = "total_amount";
             $col["width"] = "20";
             $col['align'] = "right";
             $col['formatter'] = "currency";
             $col["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
             $col["editable"] = true;
             // this column is editable
             $col["editoptions"] = array("size" => 20);
             // with default display of textbox with size 20
             $col["editrules"] = array("required" => true, "number" => true);
             // and is required
             $cols2[] = $col;
             #Note Remark
             $col = array();
             $col["title"] = $this->lang->line('note');
             // caption of column
             $col["name"] = "note";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "30";
             $col['edittype'] = "textarea";
             $col['editoptions'] = array("rows" => '2', "cols" => '20');
             $col["editable"] = true;
             $col["formatter"] = "autocomplete";
             // autocomplete
             $col["formatoptions"] = array("sql" => "SELECT DISTINCT note as k, note as v FROM expense", "search_on" => "note", "update_field" => "note");
             $cols2[] = $col;
             # Render set columns
             $grid->set_columns($cols2);
             $e["js_on_load_complete"] = "grid2_onload";
             $e["on_insert"] = array("add_client", null, true);
             $grid->set_events($e);
             function add_client(&$data)
             {
                 $id = intval($_GET["rowid"]);
                 $data["params"]["factory_id"] = $id;
             }
             // generate grid output, with unique grid name as 'list1'
             $out_detail = $grid->render("list2");
             // Head Title
             $h2_title = $this->lang->line('car_service');
             $this->_example_output((object) array('output' => '', 'out_detail' => $out_detail, 'out_master' => $out_master, 'js_files' => array(), 'css_files' => array(), 'h2_title' => $h2_title));
         } else {
             $this->_example_output();
         }
         //end if
     } else {
         redirect('login', 'refresh');
     }
 }
Пример #15
0
 public function index()
 {
     //check login
     if ($this->session->userdata('user_name')) {
         $car = $this->car->get_Allcar();
         $g = new jqgrid();
         $carNumber = $this->input->post('carNumber');
         if (!empty($carNumber)) {
             //print_r($_POST);
             $dateStart = $this->input->post('startDate');
             $dateEnd = $this->input->post('endDate');
             /*Old*/
             #$startDate = $this->engDate($dateStart);
             #$endDate = $this->engDate($dateEnd);
             /*New*/
             #$date = $this->str2Datetime($dateStart);
             $startDate = $this->str2Datetime($dateStart);
             $endDate = $this->str2Datetime($dateEnd);
             $mktime = $date;
             $totalReceive = $this->car->total_recive($carNumber, $startDate, $endDate);
             $totalExpense = $this->car->total_expense($carNumber, $startDate, $endDate);
             $totalOil_Expense = $this->car->expense_oil($carNumber, $startDate, $endDate);
             // เติมน้ำมัน price
             $total_oilAmount = $this->car->expense_totalOil($carNumber, $startDate, $endDate);
             // เติมน้ำมัน
             //
             $Count_Order = $this->car->total_NumRecive($carNumber, $startDate, $endDate);
             $order_all = $this->car->carDetail_Orders($carNumber, $startDate, $endDate);
             $SellOil_List = $this->car->Cardetail_oilsellList($carNumber, $startDate, $endDate);
             $expensecar_list = $this->car->expense_car($carNumber, $startDate, $endDate);
             $sumTotalExpense = $totalExpense + $totalOil_Expense;
             //Summary
             $totalSummary[] = $this->car->SummaryOrders($carNumber, $startDate, $endDate);
             $totalDistance = 0;
             $totalCubic = 0;
             $totalUseoil = 0;
             $car_number = $this->car->getCar_number($carNumber);
             foreach ($totalSummary as $rows) {
                 $totalDistance = $rows['total_distance'];
                 $totalCubic = $rows['total_cubic'];
                 $totalUseoil = $rows['total_useoil'];
                 //$car_number = $rows['car_number'];
             }
             if ($totalDistance != "" and $totalCubic != "" and $Count_Order != "") {
                 if ($total_oilAmount != 0 || $total_oilAmount != "") {
                     //$aver_oil_distance = ($totalUseoil / $totalDistance);
                     /*เฉลี่ยน้ำมัน กม./ลิตร*/
                     #$aver_oil_distance = ($totalDistance/$totalUseoil);
                     $aver_oil_distance = $totalDistance / $total_oilAmount;
                     //ระยะทาง/เติมน้ำมัน
                     /*เฉลี่ยน้ำมัน ลิตร/คิว*/
                     #$aver_oil_cubic = ($totalUseoil / $totalCubic);
                     $aver_oil_cubic = $total_oilAmount / $totalCubic;
                     # เติมน้ำมัน/คิว
                     /*เฉลี่ยน้ำมัน ลิตร/เที่ยว*/
                     #$aver_oil_countOrder = ($totalUseoil / $Count_Order);
                     $aver_oil_countOrder = $total_oilAmount / $Count_Order;
                     # เติมน้ำมัน/จำนวนเที่ยว
                     /*เฉลี่ยคิว/เที่ยว*/
                     $aver_cubic_countOrder = $totalCubic / $Count_Order;
                 } else {
                     $aver_oil_distance = 0;
                     $aver_oil_cubic = 0;
                     $aver_oil_countOrder = 0;
                     #$aver_cubic_countOrder = 0;
                     #$totalDistance = 0;
                     #$totalCubic = 0;
                     #$totalUseoil = 0;
                 }
             } else {
                 $aver_oil_distance = 0;
                 $aver_oil_cubic = 0;
                 $aver_oil_countOrder = 0;
                 $aver_cubic_countOrder = 0;
                 $totalDistance = 0;
                 $totalCubic = 0;
                 $totalUseoil = 0;
             }
         }
         //End if
         if ($carNumber == "" || $startDate == "" || $endDate == "") {
             $carNumber = 0;
             $startDate = date('Y-m-d');
             $endDate = date('Y-m-d');
         }
         $carDetails[] = array("Car_number" => $car_number, "startDate" => $dateStart, "endDate" => $dateEnd, "ReciveAmount" => $totalReceive, "expenseAmount" => $totalExpense, "sumTotalExpense" => $sumTotalExpense, "OiltotalAmount" => $totalOil_Expense, "Count_Order" => $Count_Order, "totalDistance" => $totalDistance, "totalCubic" => $totalCubic, "total_oilAmount" => $total_oilAmount, "totalUseoil" => $totalUseoil, "aver_oil_distance" => $aver_oil_distance, "aver_oil_cubic" => $aver_oil_cubic, "aver_oil_countOrder" => $aver_oil_countOrder, "aver_cubic_countOrder" => $aver_cubic_countOrder);
         $g->table = $carDetails;
         $opts['autowidth'] = true;
         $opts['caption'] = "รายงาน";
         $opts['height'] = "100";
         #$opts['width'] = "990";
         // $grid["sortname"] = 'client_id'; // by default sort grid by this field
         $opts["sortorder"] = "desc";
         // ASC or DESC
         $opts["caption"] = $this->lang->line('summary_per_car');
         // caption of grid
         $opts["autowidth"] = true;
         // expand grid to screen width
         $opts["multiselect"] = false;
         // allow you to multi-select through checkboxes
         $opts["rowNum"] = 100;
         // allow you to multi-select through checkboxes
         $opts["rowList"] = array(100, 200, 500);
         $g->set_options($opts);
         //*End odf*/
         $col = array();
         $col["title"] = $this->lang->line('car_number');
         $col["name"] = "Car_number";
         $col["width"] = "40";
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('start_date');
         $col["name"] = "startDate";
         $col["width"] = "40";
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('end_date');
         $col["name"] = "endDate";
         $col["width"] = "40";
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('ReciveAmount');
         $col["name"] = "ReciveAmount";
         $col["width"] = "40";
         $col['align'] = "right";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('expenseAmount');
         $col["name"] = "expenseAmount";
         $col["width"] = "40";
         $col['align'] = "right";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         /*
                     $col["formatoptions"] = array(
         "thousandsSeparator" => ",",
         "decimalSeparator" => ".",
         "decimalPlaces" => '2');
         */
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('OiltotalAmount');
         $col["name"] = "OiltotalAmount";
         $col["width"] = "40";
         $col['align'] = "right";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('sumTotalExpense');
         $col["name"] = "sumTotalExpense";
         $col["width"] = "50";
         $col['align'] = "right";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         /*
                     $col["formatoptions"] = array(
         "thousandsSeparator" => ",",
         "decimalSeparator" => ".",
         "decimalPlaces" => '2');
         */
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('Count_Order');
         $col["name"] = "Count_Order";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         /*
         $col["formatoptions"] = array(
             "thousandsSeparator" => ",",
             "decimalSeparator" => ".",
             "decimalPlaces" => '2');
         */
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('totalDistance');
         $col["name"] = "totalDistance";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         /*
         $col["formatoptions"] = array(
             "thousandsSeparator" => ",",
             "decimalSeparator" => ".",
             "decimalPlaces" => '2');
         */
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('totalCubic');
         $col["name"] = "totalCubic";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         /*
         $col["formatoptions"] = array(
             "thousandsSeparator" => ",",
             "decimalSeparator" => ".",
             "decimalPlaces" => '2');
         */
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('total_oil');
         $col["name"] = "total_oilAmount";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         /*
         $col["formatoptions"] = array(
             "thousandsSeparator" => ",",
             "decimalSeparator" => ".",
             "decimalPlaces" => '2');
         */
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('totalUseoil');
         $col["name"] = "totalUseoil";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         /*
         $col["formatoptions"] = array(
             "thousandsSeparator" => ",",
             "decimalSeparator" => ".",
             "decimalPlaces" => '2');
         */
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('aver_oil_distance');
         $col["name"] = "aver_oil_distance";
         $col["width"] = "40";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         $col['align'] = "center";
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('aver_oil_cubic');
         $col["name"] = "aver_oil_cubic";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('aver_oil_countOrder');
         $col["name"] = "aver_oil_countOrder";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('aver_cubic_countOrder');
         $col["name"] = "aver_cubic_countOrder";
         $col["width"] = "40";
         $col['align'] = "center";
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
         $cols[] = $col;
         $g->set_columns($cols);
         //Group
         $g->set_group_header(array("useColSpanStyle" => true, "groupHeaders" => array(array("startColumnName" => 'expenseAmount', "numberOfColumns" => 3, "titleText" => 'รายจ่าย'), array("startColumnName" => 'Count_Order', "numberOfColumns" => 8, "titleText" => $this->lang->line('Other_Average')))));
         $g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'add'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'edit'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'delete'), "rowactions" => true, "export" => false, "autofilter" => false, "search" => false));
         $out_master = $g->render("list1");
         if (isset($order_all)) {
             $g2 = new jqgrid();
             //Column Option
             #date
             $col2 = array();
             $col2['title'] = $this->lang->line("date");
             $col2['name'] = "Order_date";
             $col2['width'] = "120";
             $cols2[] = $col2;
             #dpNumber
             $col2 = array();
             $col2['title'] = $this->lang->line("dp_number");
             $col2['name'] = "Dpnumber";
             $col2['width'] = "80";
             $col2['align'] = "left";
             $cols2[] = $col2;
             #FactoryCode
             $col2 = array();
             $col2['title'] = $this->lang->line("factory_code");
             $col2['name'] = "FactoryCode";
             $col2['width'] = "80";
             $col2['align'] = "center";
             $cols2[] = $col2;
             #DistanceCode
             $col2 = array();
             $col2['title'] = $this->lang->line("distance_code");
             $col2['name'] = "DistanceCode";
             $col2['width'] = "80";
             $col2['align'] = "center";
             $cols2[] = $col2;
             #RealDistance
             $col2 = array();
             $col2['title'] = $this->lang->line('real_distance');
             $col2['name'] = "RealDistance";
             $col2['width'] = "80";
             $col2['align'] = "center";
             $cols2[] = $col2;
             #cubic_code
             $col2 = array();
             $col2['title'] = $this->lang->line('cubic_code');
             $col2['name'] = "cubic_value";
             $col2['width'] = "80";
             $col2['align'] = "center";
             $cols2[] = $col2;
             #car_number
             $col2 = array();
             $col2['title'] = $this->lang->line('car_number');
             $col2['name'] = "car_number";
             $col2['width'] = "80";
             $col2['align'] = "center";
             $cols2[] = $col2;
             #driver_name
             $col2 = array();
             $col2['title'] = $this->lang->line('driver');
             $col2['name'] = "driver_name";
             $col2['width'] = "120";
             $cols2[] = $col2;
             #Select Table
             $g2->table = $order_all;
             $g2->set_columns($cols2);
             //$opt['width'] ="770";
             $opt['rowNum'] = 10;
             $opt['height'] = "300";
             $opt['rowList'] = array(10, 20, 30);
             $g2->set_options($opt);
             $out_order = $g2->render("list2");
         }
         //Oil Detail
         if (isset($SellOil_List)) {
             $g3 = new jqgrid();
             #set Column
             $col3 = array();
             $col3['title'] = $this->lang->line('date');
             $col3['name'] = "Date";
             $cols3[] = $col3;
             #Factory_code
             $col3 = array();
             $col3['title'] = $this->lang->line('factory_code');
             $col3['name'] = "Factory_code";
             $cols3[] = $col3;
             #Factory_code
             $col3 = array();
             $col3['title'] = $this->lang->line('factory_name');
             $col3['name'] = "factory_name";
             $cols3[] = $col3;
             #Ref_Number
             $col3 = array();
             $col3['title'] = $this->lang->line('reference_number');
             $col3['name'] = "ref_number";
             $cols3[] = $col3;
             #Details
             $col3 = array();
             $col3['title'] = $this->lang->line('stock_details');
             $col3['name'] = "Details";
             $cols3[] = $col3;
             #Oil Value
             $col3 = array();
             $col3['title'] = $this->lang->line('sell_oil');
             $col3['name'] = "SellOil";
             $col3['align'] = "center";
             $col3['formatter'] = "number";
             $col3["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".");
             $cols3[] = $col3;
             #oil_price
             $col3 = array();
             $col3['title'] = $this->lang->line('list_per_price');
             $col3['name'] = 'Sell_price';
             $col3['align'] = "right";
             $col3['formatter'] = "currency";
             $col3["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".");
             $cols3[] = $col3;
             #total_mount
             $col3 = array();
             $col3['title'] = $this->lang->line('total_amount');
             $col3['name'] = 'TotalAmount';
             $col3['align'] = "right";
             $col3['formatter'] = "currency";
             $col3["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".");
             $cols3[] = $col3;
             #Carnumber
             $col3 = array();
             $col3['title'] = $this->lang->line('car_number');
             $col3['name'] = "Carnumber";
             #$cols3[] = $col3;
             #select table
             $g3->table = $SellOil_List;
             #set column
             $g3->set_columns($cols3);
             /*Option*/
             $opt3["caption"] = $this->lang->line('sell_oil_list');
             #$opt3["sortname"] = 'stock_id';
             # $opt3["sortorder"] = "desc";
             $opt3["height"] = "250";
             $opt3["width"] = "920";
             $opt3['rowNum'] = 10;
             $opt3['rowList'] = array(10, 20, 30);
             //$opt3["width"] = "600";
             #$opt3["autowidth"] = true;
             $g3->set_options($opt3);
             $out_oilList = $g3->render("list3");
         }
         // Other Expense for car
         if (isset($expensecar_list)) {
             $g4 = new jqgrid();
             $col4 = array();
             $col4['title'] = $this->lang->line('date');
             $col4['name'] = "Date";
             $cols4[] = $col4;
             $col4 = array();
             $col4['title'] = $this->lang->line('factory_code');
             $col4['name'] = "FactoryCode";
             $cols4[] = $col4;
             $col4 = array();
             $col4['title'] = $this->lang->line('reference_number');
             $col4['name'] = "Ref.Number";
             $cols4[] = $col4;
             $col4 = array();
             $col4['title'] = $this->lang->line('Details');
             $col4['name'] = "Details";
             $cols4[] = $col4;
             $col4 = array();
             $col4['title'] = $this->lang->line('total_amount');
             $col4['name'] = "TotalAmount";
             $cols4[] = $col4;
             $col4 = array();
             $col4['title'] = $this->lang->line('remark');
             $col4['name'] = "Remark";
             $cols4[] = $col4;
             $g4->table = $expensecar_list;
             $g4->set_columns($cols4);
             $opt4['height'] = "250";
             $opt4["autowidth"] = true;
             $opt4["autoresize"] = true;
             $opt4['rowNum'] = 10;
             $opt4['rowList'] = array(10, 20, 30);
             $g4->set_options($opt4);
             $out_expensecarList = $g4->render("list4");
         }
         // end if
         //Display
         $this->_example_output((object) array('output' => '', 'car' => $car, 'mktime' => $mktime, 'out_master' => $out_master, 'car_detail' => $carDetails, 'out_oilList' => $out_oilList, 'out_expensecarList' => $out_expensecarList, 'totalSummary' => $totalSummary, "out_order" => $out_order));
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Пример #16
0
 public function index()
 {
     //check login
     if ($this->session->userdata('user_name')) {
         $g = new jqgrid();
         $opt["caption"] = "รายการรับ - จ่าย น้ำมัน";
         // following params will enable subgrid -- by default first column (PK) of parent is passed as param 'id'
         $opt["detail_grid_id"] = "list2,list3";
         $opt["subgridparams"] = "factory_id";
         $opt["height"] = "90";
         $opt['autowidth'] = true;
         $g->set_options($opt);
         $col = array();
         $col['title'] = "id";
         $col['name'] = "factory_id";
         $col['hidden'] = true;
         // $col['dbname'] = "fac.factory_id";
         $cols[] = $col;
         #factory Name
         $col = array();
         $col['title'] = $this->lang->line('factory_name');
         $col['name'] = "factory_name";
         //$col['dbnaem'] = "fac.factory_name";
         $col["search"] = false;
         $cols[] = $col;
         #factory Code
         $col = array();
         $col['title'] = $this->lang->line('factory_code');
         $col['name'] = "factory_code";
         $col['dbnaem'] = "fac.factory_code";
         $col["search"] = false;
         $cols[] = $col;
         #Recived Oil
         $col = array();
         $col['title'] = $this->lang->line('sum_recived_oil');
         $col['name'] = "receive_oil";
         $col["search"] = false;
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => 2);
         $cols[] = $col;
         #Sell Oil
         $col = array();
         $col['title'] = $this->lang->line('sum_sell_oil');
         $col['name'] = "sell_oil";
         $col["search"] = false;
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => 2);
         $cols[] = $col;
         #Total Amount
         $col = array();
         $col['title'] = $this->lang->line("oil_total_amount");
         $col['name'] = "total_amount";
         $col["search"] = false;
         $col["formatter"] = "number";
         $col["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => 2);
         $cols[] = $col;
         // Command 1
         $g->select_command = "SELECT\n     factory_id,\n     factory_code,\n     factory_name,\n     SUM(receive_oil) AS receive_oil,\n     SUM(sell_oil) AS sell_oil,\n     oil_type,\n     SUM(receive_oil - sell_oil) AS total_amount,\n\t\t factory_status\nFROM\n     (\n          SELECT\n               t1.factory_id,\n               t1.factory_code,\n               t1.factory_name,\n\t\t\t\t\t\t\t t1.factory_status,\n               t2.receive_oil,\n               t2.sell_oil,\n               t2.oil_type\n          FROM\n               transport_factory AS t1\n          LEFT JOIN oilstock AS t2 ON t1.factory_id = t2.factory_id\n          UNION\n               SELECT\n                    t1.factory_id,\n                    t1.factory_code,\n                    t1.factory_name,\n\t\t\t\t\t\t\t\t\t\tt1.factory_status,\n                    t2.receive_oil,\n                    t2.sell_oil,\n                    t2.oil_type\n               FROM\n                    transport_factory AS t1\n               RIGHT JOIN oilstock AS t2 ON t1.factory_id = t2.factory_id\n     ) oilstock\nGROUP BY\n     factory_id\nHAVING factory_status =1";
         $g->table = "transport_factory";
         $g->set_columns($cols);
         $g->set_actions(array("add" => false, "edit" => false, "delete" => false, "rowactions" => false, "autofilter" => false));
         // render grid and get html/js output
         $out_master = $g->render("list1");
         /*
         if (!empty($_REQUEST["factory_id"]))
         {
         $_SESSION["factory_id"] = intval($_REQUEST["factory_id"]);
         }
         
         if (isset($_SESSION['factory_id']))
         {
         $fac_id = $_SESSION["factory_id"];
         } else
         {
         $fac_id = "0";
         }
         */
         $fac_id = intval($_GET["factory_id"]);
         #Detail Oil Recive **รับน้ำมัน
         $g2 = new jqgrid();
         /*Option*/
         $opt2["caption"] = $this->lang->line("recived_oil_list");
         $opt2["sortname"] = 'stock_id';
         $opt2["sortorder"] = "desc";
         $opt2["height"] = "250";
         $opt2['rowNum'] = 10;
         $opt2['rowList'] = array(10, 20, 30);
         $opt2["width"] = "979";
         //$opt2["autowidth"] = true;
         //$opt3['hidegrid'] = true;
         $opt2["form"]["position"] = "center";
         $opt2["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt2["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         /*
         $opt2["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('จำเป็นต้องเลือกโรงงาน'); return false; } }";
         $opt2["add_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
         $opt2["edit_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
         $opt2["delete_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
         $opt2["add_options"]["afterShowForm"] =
         'function(formid) { jQuery("#ref_number").focus(); }';
         */
         // Check if master record is selected before detail addition
         $opt2["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('คุณยังไม่ได้เลือกโรงงาน'); return false; } }";
         // reload master after detail update
         $opt2["onAfterSave"] = "function(){ jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); }";
         $g2->set_options($opt2);
         #id
         $col2 = array();
         $col2['title'] = "id";
         $col2['name'] = 'stock_id';
         $col2['hidden'] = true;
         $col2['editable'] = true;
         $cols2[] = $col2;
         #stick date
         $col2 = array();
         $col2['title'] = $this->lang->line('date');
         $col2['name'] = 'stock_date';
         $col2['editable'] = true;
         $col2["editrules"] = array("required" => true);
         // and is required
         //$col2["editoptions"] = array("size" => 20, "defaultValue" => date("d-m-Y H:i")); // with default display of textbox with size 20
         $col2["searchoptions"]["sopt"] = array("cn");
         // contains search for easy searching
         # to make it date time
         $col2["formatter"] = "datetime";
         # opts array can have these options: http://trentrichardson.com/examples/timepicker/#tp-options
         $col2["formatoptions"] = array("srcformat" => 'Y-m-d H:i:s', "newformat" => 'Y-m-d H:i', "opts" => array("timeFormat" => "HH:mm"));
         $col2["show"] = array("list" => true, "add" => true, "edit" => true, "view" => true);
         $cols2[] = $col2;
         #Ref No.
         $col2 = array();
         $col2['title'] = $this->lang->line('reference_number');
         $col2['name'] = 'ref_number';
         $col2['editable'] = true;
         $cols2[] = $col2;
         $col2 = array();
         $col2['title'] = $this->lang->line('customer_type');
         $col2['name'] = "customer_type_id";
         $col2['dbname'] = "oil.customer_type_id";
         $col2["editable"] = true;
         $col2["edittype"] = "select";
         $col2["editrules"] = array("required" => true);
         $str = $g2->get_dropdown_values("SELECT DISTINCT customer_type_id AS k,customer_type_title AS v FROM transport_customer_type WHERE customer_type_status = '2'");
         $col2["editoptions"] = array("value" => ":;" . $str);
         $col2["editoptions"] = array("value" => $str, "onchange" => array("sql" => "SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers WHERE customer_type_id ='{customer_type_id}' ", "update_field" => "customer_id"));
         $col2["formatter"] = "select";
         // display label, not value
         $col2["stype"] = "select";
         // enable dropdown search
         $col2["searchoptions"] = array("value" => ":;" . $str);
         $cols2[] = $col2;
         # Customer Name
         $col2 = array();
         $col2['title'] = $this->lang->line('customer_br');
         $col2['name'] = "customer_id";
         $col2['dbname'] = "oil.customer_id";
         $col2["editable"] = true;
         $col2["edittype"] = "select";
         $col2["editrules"] = array("required" => true);
         $str = $g2->get_dropdown_values("SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers ");
         $col2["editoptions"] = array("value" => ":;" . $str);
         $col2["editoptions"] = array("value" => $str, "onchange" => array("sql" => "SELECT DISTINCT car_id AS k,car_number AS v FROM `transport_oilcars` WHERE customer_id ='{customer_id}' AND `status`=1", "update_field" => "car_id"));
         $col2["editoptions"]["onload"]["sql"] = "SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers WHERE customer_type_id ='{customer_type_id}' AND `status` =1";
         $col2["formatter"] = "select";
         // display label, not value
         $col2["stype"] = "select";
         // enable dropdown search
         $col2["searchoptions"] = array("value" => ":;" . $str);
         $cols2[] = $col2;
         #Car Number
         $col2 = array();
         $col2['title'] = $this->lang->line('car_number');
         $col2['name'] = "car_id";
         $col2['dbname'] = "car.car_id";
         $col2["editable"] = true;
         $col2["edittype"] = "select";
         $col2["editrules"] = array("required" => true);
         $str = $g2->get_dropdown_values("SELECT DISTINCT car_id AS k, car_number AS v FROM transport_oilcars WHERE  `status` =1");
         $col2["editoptions"] = array("value" => ":;" . $str);
         // initially load 'note' of that
         $col2["editoptions"]["onload"]["sql"] = "SELECT DISTINCT car_id AS k, car_number AS v FROM transport_oilcars WHERE customer_id = '{customer_id}' AND `status` =1";
         $col2["formatter"] = "select";
         // display label, not value
         $col2["stype"] = "select";
         // enable dropdown search
         $col2["searchoptions"] = array("value" => ":;" . $str);
         $cols2[] = $col2;
         #stock_details
         $col2 = array();
         $col2['title'] = $this->lang->line('stock_details');
         $col2['name'] = 'stock_details';
         $col2['editable'] = true;
         $col2["edittype"] = "textarea";
         $col2["editoptions"] = array("rows" => 2, "cols" => 20);
         $col2["formatter"] = "autocomplete";
         // autocomplete
         $col2["formatoptions"] = array("sql" => "SELECT DISTINCT stock_details as k, stock_details as v FROM oilstock", "search_on" => "stock_details", "update_field" => "stock_details");
         $cols2[] = $col2;
         #oil_value
         $col2 = array();
         $col2['title'] = $this->lang->line('recived_oil');
         $col2['name'] = 'receive_oil';
         $col2['editable'] = true;
         $col2['search'] = false;
         $col2["editrules"] = array("required" => true, "number" => true);
         $col2["editoptions"] = array("onblur" => "update_reciveValue()", "defaultValue" => '0');
         $col2['formatter'] = "number";
         $col2["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $cols2[] = $col2;
         #oil_value
         $col2 = array();
         $col2['title'] = $this->lang->line('list_per_price');
         $col2['name'] = 'receive_price';
         $col2['align'] = "right";
         $col2['editable'] = true;
         #$col2['formatter'] = "number";
         $col2['search'] = false;
         $col2["editrules"] = array("required" => true, "number" => true);
         $col2["editoptions"] = array("onblur" => "update_reciveValue()", "defaultValue" => '0');
         $col2['formatter'] = "currency";
         $col2["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $cols2[] = $col2;
         #total_mount
         $col2 = array();
         $col2['title'] = $this->lang->line('total_amount');
         $col2['name'] = 'receive_amount';
         $col2['align'] = "right";
         $col2['editable'] = true;
         $col2["editrules"] = array("required" => true);
         # $col2['editoptions'] = array("readonly" => "readonly");
         $col2['search'] = false;
         $col2['formatter'] = "currency";
         $col2["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => 2);
         $cols2[] = $col2;
         // $id = intval($_GET["rowid"]);
         /*
                     $g2->select_command = "SELECT
                     stock_id,
                     stock_date,
                     ref_number,
                     oil.customer_type_id,
                     cus_type.customer_type_title,
                     oil.customer_id,
                     cus.customers_name,
                     oil.car_id,
                     car.car_number,	
                     stock_details,
                     
                     receive_oil,
                     receive_price,
                     receive_amount
                     FROM
                     oilstock AS oil
                     LEFT JOIN transport_cars AS car ON (oil.car_id = car.car_id)
                     LEFT JOIN transport_customers AS cus ON (
                     oil.customer_id = cus.customer_id
                     )
                     LEFT JOIN transport_customer_type AS cus_type ON (
                     cus.customer_type_id = cus_type.customer_type_id
                     )
                     WHERE
                     oil.factory_id = '$fac_id'
                     AND oil_type = 1";
         */
         $g2->select_command = "SELECT\n\tstock_id,\n\tstock_date,\n\tref_number,\n\toil.customer_type_id,\n\tcus_type.customer_type_title,\n\toil.customer_id,\n\tcus.customer_name,\n\toil.car_id,\n\tcar.car_number,\t\n    stock_details,\n\t\n\treceive_oil,\n\treceive_price,\n\treceive_amount\nFROM\n\toilstock AS oil\nLEFT JOIN transport_cars AS car ON (oil.car_id = car.car_id)\nLEFT JOIN transport_oilcustomers AS cus ON (\n\toil.customer_id = cus.customer_id\n)\nLEFT JOIN transport_customer_type AS cus_type ON (\n\tcus.customer_type_id = cus_type.customer_type_id\n)\nWHERE\n\toil.factory_id = '{$fac_id}'\nAND oil_type = 1";
         #select table
         $g2->table = "oilstock";
         #$g2->table = "oil_receive";
         $e["on_insert"] = array("add_client", null, true);
         $g2->set_events($e);
         function add_client(&$data)
         {
             $id = intval($_GET["rowid"]);
             $data["params"]["factory_id"] = $id;
             $data["params"]["oil_type"] = 1;
         }
         $g2->set_actions(array("add" => true, "edit" => true, "delete" => true, "view" => false, "rowactions" => false, "autofilter" => true, "search" => "advance", "inlineadd" => false, "showhidecolumns" => false));
         $g2->set_columns($cols2);
         #display Grid2
         $out_list2 = $g2->render("list2");
         /*Grid3 รายการจ่ายน้ำมัน*/
         $g3 = new jqgrid();
         /*Option*/
         $opt3["caption"] = $this->lang->line('sell_oil_list');
         $opt3["sortname"] = 'stock_id';
         $opt3["sortorder"] = "desc";
         $opt3["height"] = "250";
         $opt3['rowNum'] = 10;
         $opt3['rowList'] = array(10, 20, 30);
         $opt3["width"] = "979";
         //$opt3["autowidth"] = true;
         //$opt3['hidegrid'] = true;
         $opt3["form"]["position"] = "center";
         $opt3["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt3["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         /*
         $opt3["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('จำเป็นต้องเลือกโรงงาน'); return false; } }";
         $opt3["add_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
         $opt3["edit_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
         $opt3["delete_options"]["afterSubmit"] = "function(){jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return true;}";
         $opt3["add_options"]["afterShowForm"] =
         'function(formid) { jQuery("#ref_number").focus(); }';
         */
         // Check if master record is selected before detail addition
         $opt3["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('คุณยังไม่ได้เลือกโรงงาน'); return false; } }";
         // reload master after detail update
         $opt3["onAfterSave"] = "function(){ jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); }";
         $g3->set_options($opt3);
         #id
         $col3 = array();
         $col3['title'] = "id";
         $col3['name'] = 'stock_id';
         $col3['hidden'] = true;
         $col3['editable'] = true;
         $cols3[] = $col3;
         #stick date
         $col3 = array();
         $col3['title'] = $this->lang->line('date');
         $col3['name'] = 'stock_date';
         $col3['editable'] = true;
         $col3["editrules"] = array("required" => true);
         // and is required
         //$col2["editoptions"] = array("size" => 20, "defaultValue" => date("d-m-Y H:i")); // with default display of textbox with size 20
         $col3["searchoptions"]["sopt"] = array("cn");
         // contains search for easy searching
         # to make it date time
         $col3["formatter"] = "datetime";
         # opts array can have these options: http://trentrichardson.com/examples/timepicker/#tp-options
         $col3["formatoptions"] = array("srcformat" => 'Y-m-d H:i:s', "newformat" => 'Y-m-d H:i', "opts" => array("timeFormat" => "HH:mm"));
         $col3["show"] = array("list" => true, "add" => true, "edit" => true, "view" => true);
         $cols3[] = $col3;
         #Ref No.
         $col3 = array();
         $col3['title'] = $this->lang->line('reference_number');
         $col3['name'] = 'ref_number';
         $col3['editable'] = true;
         $cols3[] = $col3;
         $col3 = array();
         $col3['title'] = $this->lang->line('customer_type');
         $col3['name'] = "customer_type_id";
         $col3['dbname'] = "oil.customer_type_id";
         $col3["editable"] = true;
         $col3["edittype"] = "select";
         $col3["editrules"] = array("required" => true);
         $str = $g3->get_dropdown_values("SELECT DISTINCT customer_type_id AS k,customer_type_title AS v FROM transport_customer_type WHERE customer_type_status = '2'");
         $col3["editoptions"] = array("value" => ":;" . $str);
         $col3["editoptions"] = array("value" => $str, "onchange" => array("sql" => "SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers WHERE customer_type_id ='{customer_type_id}' ", "update_field" => "customer_id"));
         $col3["formatter"] = "select";
         // display label, not value
         $col3["stype"] = "select";
         // enable dropdown search
         $col3["searchoptions"] = array("value" => ":;" . $str);
         $cols3[] = $col3;
         # Customer Name
         $col3 = array();
         $col3['title'] = $this->lang->line('customer_br');
         $col3['name'] = "customer_id";
         $col3['dbname'] = "oil.customer_id";
         $col3["editable"] = true;
         $col3["edittype"] = "select";
         $col3["editrules"] = array("required" => true);
         $str = $g3->get_dropdown_values("SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers ");
         $col3["editoptions"] = array("value" => ":;" . $str);
         $col3["editoptions"] = array("value" => $str, "onchange" => array("sql" => "SELECT DISTINCT car_id AS k,car_number AS v FROM `transport_oilcars` WHERE customer_id ='{customer_id}' AND `status`=1", "update_field" => "car_id"));
         $col3["editoptions"]["onload"]["sql"] = "SELECT DISTINCT customer_id AS k , customer_name AS v FROM transport_oilcustomers WHERE customer_type_id ='{customer_type_id}' AND `status` =1";
         $col3["formatter"] = "select";
         // display label, not value
         $col3["stype"] = "select";
         // enable dropdown search
         $col3["searchoptions"] = array("value" => ":;" . $str);
         $cols3[] = $col3;
         #Car Number
         $col3 = array();
         $col3['title'] = $this->lang->line('car_number');
         $col3['name'] = "car_id";
         $col3['dbname'] = "car.car_id";
         $col3["editable"] = true;
         $col3["edittype"] = "select";
         $col3["editrules"] = array("required" => true);
         $str = $g3->get_dropdown_values("SELECT DISTINCT car_id AS k, car_number AS v FROM transport_oilcars WHERE  `status` =1");
         $col3["editoptions"] = array("value" => ":;" . $str);
         // initially load 'note' of that
         $col3["editoptions"]["onload"]["sql"] = "SELECT DISTINCT car_id AS k, car_number AS v FROM transport_oilcars WHERE customer_id = '{customer_id}' AND `status` =1";
         $col3["formatter"] = "select";
         // display label, not value
         $col3["stype"] = "select";
         // enable dropdown search
         $col3["searchoptions"] = array("value" => ":;" . $str);
         $cols3[] = $col3;
         #stock_details
         $col3 = array();
         $col3['title'] = $this->lang->line('stock_details');
         $col3['name'] = 'stock_details';
         $col3['editable'] = true;
         $col3["edittype"] = "textarea";
         $col3["editoptions"] = array("rows" => 2, "cols" => 20);
         $col3["formatter"] = "autocomplete";
         // autocomplete
         $col3["formatoptions"] = array("sql" => "SELECT DISTINCT stock_details as k, stock_details as v FROM oilstock", "search_on" => "stock_details", "update_field" => "stock_details");
         $cols3[] = $col3;
         #oil_value
         $col3 = array();
         $col3['title'] = $this->lang->line('sell_oil');
         $col3['name'] = 'sell_oil';
         $col3['search'] = false;
         $col3['editable'] = true;
         $col3["editrules"] = array("required" => true, "number" => true);
         $col3["editoptions"] = array("onblur" => "update_oilvalue()", "defaultValue" => '0');
         $col3['formatter'] = "number";
         $col3["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $cols3[] = $col3;
         #oil_price
         $col3 = array();
         $col3['title'] = $this->lang->line('list_per_price');
         $col3['name'] = 'sell_price';
         $col3['align'] = "right";
         $col3['editable'] = true;
         $col3['search'] = false;
         $col3["editrules"] = array("required" => true, "number" => true);
         $col3["editoptions"] = array("onblur" => "update_oilvalue()", "defaultValue" => '0');
         $col3['formatter'] = "currency";
         $col3["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $cols3[] = $col3;
         #total_mount
         $col3 = array();
         $col3['title'] = $this->lang->line('total_amount');
         $col3['name'] = 'sell_amount';
         $col3['align'] = "right";
         $col3['editable'] = true;
         $col3['search'] = false;
         $col3["editrules"] = array("required" => true);
         #$col3['editoptions'] = array("readonly" => "readonly");
         $col3['formatter'] = "currency";
         $col3["formatoptions"] = array("thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
         $cols3[] = $col3;
         //$fac_id = intval($_REQUEST["rowid"]);
         /*
         $g3->select_command = "SELECT
         stock_id,
         stock_date,
         ref_number,
         oil.customer_type_id,
         cus_type.customer_type_title,
         oil.customer_id,
         cus.customers_name,
         oil.car_id,
         car.car_number,
         stock_details,
         sell_oil,
         sell_price,
         sell_amount
         FROM
         oilstock AS oil
         LEFT JOIN transport_cars AS car ON (oil.car_id = car.car_id)
         LEFT JOIN transport_customers AS cus ON (
         oil.customer_id = cus.customer_id
         )
         LEFT JOIN transport_customer_type AS cus_type ON (
         cus.customer_type_id = cus_type.customer_type_id
         )
         WHERE
         oil.factory_id = '$fac_id'
         AND oil_type = 2";
         */
         $g3->select_command = "SELECT\n\tstock_id,\n\tstock_date,\n\tref_number,\n\toil.customer_type_id,\n\tcus_type.customer_type_title,\n\toil.customer_id,\n\tcus.customer_name,\n\toil.car_id,\n\tcar.car_number,\n\tstock_details,\n\tsell_oil,\n\tsell_price,\n\tsell_amount\nFROM\n\toilstock AS oil\nLEFT JOIN transport_cars AS car ON (oil.car_id = car.car_id)\nLEFT JOIN transport_oilcustomers AS cus ON (\n\toil.customer_id = cus.customer_id\n)\nLEFT JOIN transport_customer_type AS cus_type ON (\n\tcus.customer_type_id = cus_type.customer_type_id\n)\nWHERE\n\toil.factory_id = '{$fac_id}'\nAND oil_type = 2";
         $g3->table = "oilstock";
         $e["on_insert"] = array("add_oiltype", null, true);
         $g3->set_events($e);
         function add_oiltype(&$data)
         {
             $id = intval($_GET["rowid"]);
             $data["params"]["factory_id"] = $id;
             $data["params"]["oil_type"] = 2;
         }
         $g3->set_columns($cols3);
         $g3->set_actions(array("add" => true, "edit" => true, "delete" => true, "view" => false, "rowactions" => true, "autofilter" => true, "search" => "advance", "inlineadd" => false, "showhidecolumns" => false));
         #display Grid2
         $out_list3 = $g3->render("list3");
         //display
         $this->_example_output((object) array('output' => '', 'out_master' => $out_master, 'out_list2' => $out_list2, 'out_list3' => $out_list3));
         //$this->load->view('oil/oil-view');
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Пример #17
0
 public function index()
 {
     if ($this->session->userdata('user_name')) {
         $g = new jqgrid();
         $g->select_command = "SELECT id,fac.factory_code as factory_id ,dis.distance_code as distance_id,cubic.cubic_value as cubic_id,pr.price, start_date,end_date FROM pricelist as pr \nLEFT JOIN transport_factory as fac ON(pr.factory_id=fac.factory_id)\nLEFT JOIN transport_cubiccode as cubic ON(pr.cubic_id = cubic.cubic_id)\nLEFT JOIN distancecode as dis ON(pr.distance_id=dis.distance_id)";
         $g->table = "pricelist";
         $col = array();
         $col["title"] = "id";
         $col["name"] = "id";
         //$col["dbname"] = "pr.pricelist_id";
         $col["width"] = "10";
         $col["hidden"] = true;
         $col["editable"] = false;
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('factory_code');
         // caption of column
         $col["name"] = "factory_id";
         $col["dbname"] = "pr.factory_id";
         $col["width"] = "10";
         $col["align"] = "left";
         $col["search"] = true;
         $col["editable"] = true;
         $col["editrules"] = array("required" => true);
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         $str = $g->get_dropdown_values("SELECT DISTINCT factory_id AS k,factory_code AS v FROM transport_factory");
         $col["editoptions"] = array("value" => ":;" . $str);
         // multi-select in search filter
         $col["stype"] = "select-multiple";
         $col["searchoptions"]["value"] = $str;
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('distance_code');
         // caption of column
         $col["name"] = "distance_id";
         $col["dbname"] = "pr.distance_id";
         $col["width"] = "10";
         $col["align"] = "left";
         $col["search"] = true;
         $col["editable"] = true;
         $col["editrules"] = array("required" => true);
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         $str = $g->get_dropdown_values("SELECT DISTINCT distance_id AS k,distance_code AS v FROM distancecode WHERE distance_status=1");
         $col["editoptions"] = array("value" => ":;" . $str);
         // multi-select in search filter
         $col["stype"] = "select-multiple";
         $col["searchoptions"]["value"] = $str;
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('cubic_value');
         // caption of column
         $col["name"] = "cubic_id";
         $col["dbname"] = "pr.cubic_id";
         $col["width"] = "10";
         $col["align"] = "left";
         $col["search"] = true;
         $col["editable"] = true;
         $col["editrules"] = array("required" => true);
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         $str = $g->get_dropdown_values("SELECT DISTINCT cubic_id AS k,cubic_value AS v FROM transport_cubiccode WHERE cubic_status=1");
         $col["editoptions"] = array("value" => ":;" . $str);
         // multi-select in search filter
         $col["stype"] = "select-multiple";
         $col["searchoptions"]["value"] = $str;
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('price');
         // caption of column
         $col["name"] = "price";
         $col["editable"] = true;
         $col["width"] = "10";
         $col["editrules"] = array("required" => true);
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('start_date');
         // caption of column
         $col["name"] = "start_date";
         $col["formatter"] = "date";
         // format as date
         $col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd/m/Y');
         // http://docs.jquery.com/UI/Datepicker/formatDate
         $col["width"] = "10";
         $col["editrules"] = array("required" => true);
         $col["editable"] = true;
         $cols[] = $col;
         $col = array();
         $col["title"] = $this->lang->line('end_date');
         // caption of column
         $col["name"] = "end_date";
         $col["formatter"] = "date";
         // format as date
         $col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd/m/Y');
         // http://docs.jquery.com/UI/Datepicker/formatDate
         $col["width"] = "10";
         $col["editrules"] = array("required" => true);
         $col["editable"] = true;
         $cols[] = $col;
         $g->set_columns($cols);
         $g->set_actions(array("add" => true, "edit" => true, "delete" => true, "clone" => true, "rowactions" => true, "search" => "advance", "showhidecolumns" => false));
         // $grid["url"] = ""; // your paramterized URL -- defaults to REQUEST_URI
         $grid["rowNum"] = 50;
         // by default 20
         $grid["sortname"] = 'id';
         // by default sort grid by this field
         $grid["sortorder"] = "desc";
         // ASC or DESC
         $grid["caption"] = $this->lang->line('pricelist');
         // caption of grid
         $grid["autowidth"] = true;
         // expand grid to screen width
         $grid["multiselect"] = true;
         // allow you to multi-select through checkboxes
         $grid["form"]["position"] = "center";
         $grid["altRows"] = true;
         $grid["altclass"] = "myAltRowClass";
         $grid["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $grid["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $g->set_options($grid);
         $e["on_update"] = array("update_price", null, true);
         $e["on_insert"] = array("add_price", null, true);
         $g->set_events($e);
         function add_price(&$data)
         {
             $factory_id = $data["params"]["factory_id"];
             $distance_id = $data["params"]["distance_id"];
             $cubic_id = $data["params"]["cubic_id"];
             $start_date = $data["params"]["start_date"];
             $end_date = $data["params"]["end_date"];
             $check_sql = "SELECT COUNT(*) AS c\nFROM\n\tpricelist\nWHERE\n\tfactory_id = '{$factory_id}'\nAND distance_id = '{$distance_id}'\nAND cubic_id = '{$cubic_id}'\nAND ( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$start_date}','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$start_date}','%Y-%m-%d'))) \nAND ( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$end_date} ','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$end_date}','%Y-%m-%d')))";
             $rs = mysql_fetch_assoc(mysql_query($check_sql));
             if ($rs["c"] > 0) {
                 phpgrid_error("ข้อมูลราคาซ้ำ ไม่สามารถบันทึกได้");
             }
         }
         // end of sub function
         function update_price(&$data)
         {
             //print_r($data);
             $obj =& get_instance();
             $obj->load->model("price_model", "price");
             $obj->load->library('conv_date');
             $price_id = $data["params"]["id"];
             //$startdate = date('Y-m-d',strtotime($data['params']['start_date']));
             $startdate = $data['params']['start_date'];
             $enddate = $data['params']['start_date'];
             $c_stdate = $obj->price->check_before_update_price($price_id);
             //$c_endate = $obj->price->check_before_update_price($price_id,$en);
             $st_date = $c_stdate['start_date'];
             $en_date = $c_stdate['end_date'];
             //$ed_date = $c_endate;
             $m_date = $obj->conv_date->compareDate($startdate, $st_date);
             $e_date = $obj->conv_date->compareDate($enddate, $st_date);
             //$m_date ="E";
             if ($m_date !== "E" && $e_date !== "E") {
                 $check_sql = "SELECT COUNT(*) as c\n\nFROM\n\tpricelist\nWHERE\n\tfactory_id = '{$data["params"]["factory_id"]}'\nAND cubic_id = '{$data["params"]["cubic_id"]}'\nAND distance_id = '{$data["params"]["distance_id"]}'\nAND ( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$data["params"]["start_date"]}','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$data["params"]["start_date"]}','%Y-%m-%d'))) \nOR\n( (start_date='0000-00-00' || start_date <= DATE_FORMAT('{$data["params"]["end_date"]}','%Y-%m-%d')) \nAND (end_date='0000-00-00' || end_date >= DATE_FORMAT('{$data["params"]["end_date"]}','%Y-%m-%d'))) LIMIT 1";
                 $rs = mysql_fetch_assoc(mysql_query($check_sql));
                 if ($rs["c"] > 0) {
                     phpgrid_error("ข้อมูลราคาซ้ำ ไม่สามารถบันทึกได้");
                 }
             }
         }
         // End of  function update_price
         //Display
         $pricetable = $g->render("list1");
         $h2_title = "Price Setting";
         $this->_example_output((object) array('output' => '', 'out' => $out, 'dispyPrice' => $dispyPrice, 'h2_title' => $h2_title, 'list_row' => $num_row, 'pricelist' => $pricelist, 'pricetable' => $pricetable));
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Пример #18
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $w9Id = intval($_POST["id"]);
            $w9 = W9::model()->with('client')->findByPk($w9Id);

            if ($w9) {
                $client = $w9->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";
                    }
                }

                $w9->Verified = $_POST["Verified"];
                $w9->Business_Name = $_POST["Business_Name"];
                $w9->Exempt = $_POST["Exempt"];
                $w9->Tax_Class = $_POST["Tax_Class"];
                $w9->Account_Nums = $_POST["Account_Nums"];
                $w9->Signed = $_POST["Account_Nums"];
                $w9->Signature_Date = $_POST["Signature_Date"] ? $_POST["Signature_Date"] : null;
                $w9->Revision_ID = $_POST["Revision_ID"];
                if ($w9->validate()) {
                    $w9->save();
                    echo "w9\n";
                }
            }

            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $w9Id = intval($_POST["id"]);
            $w9 = W9::model()->findByPk($w9Id);
            if ($w9) {
                W9::deleteW9($w9Id);
            }
            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"] = "W9 ID"; // caption of column
        $col["name"] = "W9_ID";
        $col["dbname"] = "w9.W9_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"] = "w9.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;

        $col = array();
        $col["title"] = "Business Name"; // caption of column
        $col["name"] = "Business_Name";
        $col["dbname"] = "w9.Business_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"] = false;
        $cols[] = $col;

        $col = array();
        $col["title"] = "W9 Data Entry"; // caption of column
        $col["name"] = "W9_Data_Entry";
        $col["dbname"] = "w9.W9_Data_Entry"; // 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;

        $col = array();
        $col["title"] = "Tax Class"; // caption of column
        $col["name"] = "Tax_Class";
        $col["dbname"] = "w9.Tax_Class"; // 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;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>'0:0;SP:SP;C:C;CC:CC;CS:CS;PS:PS;TE:TE;LL:LL;LC:LC;LS:LS;LP:LP;OT:OT');
        $cols[] = $col;

        $col = array();
        $col["title"] = "Exempt"; // caption of column
        $col["name"] = "Exempt";
        $col["dbname"] = "w9.Exempt"; // 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"] = false;
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

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

        $col = array();
        $col["title"] = "Signed"; // caption of column
        $col["name"] = "Signed";
        $col["dbname"] = "w9.Signed"; // 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"] = false;
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

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

        $col = array();
        $col["title"] = "Verified"; // caption of column
        $col["name"] = "Verified";
        $col["dbname"] = "w9.Verified"; // 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["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

        $revisions = W9Revisions::model()->findAll();
        $revIds[] = '-1:-1';
        $revIds[] = '0:0';
        foreach ($revisions as $revision) {
            $revIds[] = $revision->Revision_ID . ':' . $revision->Revision_ID;
        }

        $col = array();
        $col["title"] = "Revision ID"; // caption of column
        $col["name"] = "Revision_ID";
        $col["dbname"] = "w9.Revision_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;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>implode(';', $revIds));
        $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"] = "W9";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$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.*,
                                       w9.*, images.File_Name, images.Mime_Type
                              FROM w9
                              LEFT JOIN documents ON documents.Document_ID = w9.Document_ID
                              LEFT JOIN images ON images.Document_ID = documents.Document_ID
                              LEFT JOIN clients ON clients.Client_ID = w9.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 = "w9";

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'W9_ID', // group starts from this column
                        "numberOfColumns"=>11, // group span to next 2 columns
                        "titleText"=>'W9 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("w9");

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #19
0
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $id = intval($_POST["id"]);
            $video = Videos::model()->findByPk($id);
            if ($video) {

                $error_string= '';

                $video->Video_Title =$_POST['Video_Title'] ? $_POST["Video_Title"] : null;
                $video->Video_Log_Line =$_POST['Video_Log_Line'] ? $_POST["Video_Log_Line"] : null;
                $video->Video_Desc =$_POST['Video_Desc'] ? $_POST["Video_Desc"] : null;
                $video->Link_Title =$_POST['Link_Title'] ? $_POST["Link_Title"] : null;
                $video->Sort_Order =$_POST['Sort_Order'] ? $_POST["Sort_Order"] : null;
                $video->Video_URL =$_POST['Video_URL'] ? addslashes($_POST['Video_URL']) : null;
                $video->Video_Password =$_POST['Video_Password'] ? $_POST["Video_Password"] : null;
                $video->Visibility =$_POST['Visibility'] ? $_POST["Visibility"] : null;

                if (intval($_POST['Visibility'])==4) {
                    $client_id = intval($_POST['Clients_Client_ID']);
                    $client = Clients::model()->findByPk($client_id);

                    if (!$client) {
                        $error_string = 'Client_ID should be real';
                    }
                }

                if (intval($_POST['Visibility'])==5) {
                    $client_id = intval($_POST['Clients_Client_ID']);
                    $project_id = intval($_POST['Clients_Client_ID']);

                    $project = Projects::model()->findByAttributes(array(
                        'Project_ID'=>$project_id,
                        'Client_ID'=>$client_id
                    ));

                    if (!$project) {
                        $error_string = 'There is no project for such Client_ID and Project_ID';
                    }
                }
                $video->Clients_Client_ID =$_POST['Clients_Client_ID'] ? $_POST["Clients_Client_ID"] : null;
                $video->Project_ID =$_POST['Project_ID'] ? $_POST["Project_ID"] : null;



                if ($video->validate() && $error_string == '') {
                    $video->save();
                    echo "video\n";
                } else {
                    die($error_string);
                }
            }

            die;
        }

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

           // var_dump($_POST);die;
            $error_string= '';

            $video = new Videos();

            $video->Video_Title =$_POST['Video_Title'];
            $video->Video_Log_Line =$_POST['Video_Log_Line'];
            $video->Video_Desc =$_POST['Video_Desc'];
            $video->Link_Title =$_POST['Link_Title'];
            $video->Video_URL =addslashes($_POST['Video_URL']);
            $video->Video_Password =$_POST['Video_Password'];
            $video->Sort_Order =$_POST['Sort_Order'] ? $_POST["Sort_Order"] : 1;

            if (intval($_POST['Visibility'])==4) {
                $client_id = intval($_POST['Clients_Client_ID']);
                $client = Clients::model()->findByPk($client_id);

                if (!$client) {
                    $error_string = 'Client_ID should be real';
                }
            }

            if (intval($_POST['Visibility'])==5) {
                $client_id = intval($_POST['Clients_Client_ID']);
                $project_id = intval($_POST['Clients_Client_ID']);

                $project = Projects::model()->findByAttributes(array(
                    'Project_ID'=>$project_id,
                    'Client_ID'=>$client_id
                ));

                if (!$project) {
                    $error_string = 'There is no project for such Client_ID and Project_ID';
                }
            }




            $video->Visibility =$_POST['Visibility'];
            $video->Clients_Client_ID =$_POST['Clients_Client_ID'];
            $video->Project_ID =$_POST['Project_ID'];

            if ($error_string == '') {
                $video->save();
            } else {
                die($error_string);
            }


        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {

            $video_id = intval($_POST["id"]);
            $video =Videos::model()->findByPk($video_id);
            if ($video) {
                $video->delete();
            }
            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"] = "Video_ID"; // caption of column
        $col["name"] = "Video_ID";
        $col["dbname"] = "Video_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"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Video_Title"; // caption of column
        $col["name"] = "Video_Title";
        $col["dbname"] = "Video_Title"; // 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;
        $cols[] = $col;

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

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

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

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

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

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

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

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

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







        $g = new jqgrid();

        $grid["caption"] = "Videos";
        // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'Video_ID';
        $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"=>true, // 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 Videos.*
                              FROM Videos";

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

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Video_ID', // group starts from this column
                        "numberOfColumns"=>4, // group span to next 2 columns
                        "titleText"=>'Videos' // caption of group header
                    ),
                )
            )
        );

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

        $this->render('index',array(
            'out'=>$out,
        ));
    }
Пример #20
0
 function getDataGrid($id)
 {
     $g = new jqgrid();
     $pageL = $this->database->getTableLink($id);
     $type = 'gridoptions';
     $result = $this->database->getGrid1($type, $id);
     while ($row = $result->FetchRow()) {
         $value = $row[2];
         if ($row[0] != 'table' and $row[0] != 'where') {
             if ($row[1] == 'number') {
                 $value = (int) $value;
             }
             if ($row[1] == 'boolean') {
                 if ($value == 'true') {
                     $value = true;
                 } else {
                     $value = false;
                 }
             }
             $grid[$row[0]] = $value;
         }
         if ($row[0] == 'sql') {
             $value = str_replace('operatorId', $_SESSION['opridLogin'], $value);
             $g->select_command = $value;
         }
         if ($row[0] == 'table') {
             $g->table = $value;
         }
         if ($id == 'nb_factura_de_pg') {
             if (isset($_GET["factura"])) {
                 $factura = $_GET["factura"];
                 if (!is_numeric($factura)) {
                     $factura = 0;
                 }
             } else {
                 $factura = 0;
             }
             $g->select_command = "Select * from nb_detallef_tbl where factura like '" . $factura . "-%'";
         }
     }
     $campos = $this->database->getGrid2($id);
     $type = 'gridcoloptions';
     $cols = array();
     while ($camposDescribe = $campos->FetchRow()) {
         $result = $this->database->getGrid3($type, $id, $camposDescribe[0]);
         $col = array();
         while ($row = $result->FetchRow()) {
             $value = $row[2];
             if ($row[0] == 'link') {
                 $value = "nabu.php?p=" . $pageL[0] . "&accion=b&" . $value;
             }
             if ($row[0] == 'linkE') {
                 $row[0] = 'link';
             }
             if ($row[1] == 'number') {
                 $value = (int) $value;
             }
             if ($row[1] == 'boolean') {
                 if ($value == 'true') {
                     $value = true;
                 } else {
                     $value = false;
                 }
             }
             $col[$row[0]] = $value;
         }
         $cols[] = $col;
     }
     $this->database->conectar();
     $g->set_columns($cols);
     $g->set_options($grid);
     if ($id == 'nb_factura_de_pg') {
         $configGrid = true;
     } else {
         $configGrid = false;
     }
     $g->set_actions(array("add" => $configGrid, "edit" => $configGrid, "delete" => $configGrid, "rowactions" => true, "search" => "advance"));
     return $g->render("list1");
 }
Пример #21
0
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $id = intval($_POST["id"]);
            $message = CustomMessages::model()->findByPk($id);
            if ($message) {

                $error_string= '';

                $message->Message_Text = $_POST['Message_Text'] ? $_POST["Message_Text"] : ' ';
                $message->Message_Type = $_POST['Message_Type'] ? $_POST["Message_Type"] : ' ';

                if ($message->validate() && $error_string == '') {
                    $message->save();
                    echo "video\n";
                } else {
                    die($error_string);
                }
            }

            die;
        }

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

           // var_dump($_POST);die;
            $error_string= '';
            $message = new CustomMessages();
            $message->Message_Text = $_POST['Message_Text'] ? $_POST["Message_Text"] : ' ';
            $message->Message_Type = $_POST['Message_Type'] ? $_POST["Message_Type"] : ' ';

            if ($message->validate() && $error_string == '') {
                $message->save();
                
            } else {
                die($error_string);
            }

        die;
        }

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {

            $id = intval($_POST["id"]);
            $message = CustomMessages::model()->findByPk($id);
            if ($message) {
                    $message->delete();
            }

            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"] = "Message_ID"; // caption of column
        $col["name"] = "Message_ID";
        $col["dbname"] = "Message_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"] = true;
        $cols[] = $col;

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

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

        $g = new jqgrid();

        $grid["caption"] = "Custom messages";
        // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'Message_ID';
        $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"=>true, // 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 custom_messages.*
                              FROM custom_messages";

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

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Message_ID', // group starts from this column
                        "numberOfColumns"=>2, // group span to next 2 columns
                        "titleText"=>'ID' // caption of group header
                    ),
                )
            )
        );

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

        $this->render('index',array(
            'out'=>$out,
        ));
    }
Пример #22
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $vendorId = intval($_POST["id"]);
            $vendor = Vendors::model()->with('client')->findByPk($vendorId);
            if ($vendor) {
                $client = $vendor->client;
                $company = $client->company;

                $vendor->Vendor_ID_Shortcut = $_POST["Vendor_ID_Shortcut"];
                $vendor->Vendor_Name_Checkprint = $_POST["Vendor_Name_Checkprint"];
                $vendor->Vendor_1099 = $_POST["Vendor_1099"];
                $vendor->Vendor_Default_GL = $_POST["Vendor_Default_GL"];
                $vendor->Vendor_Default_GL_Note = $_POST["Vendor_Default_GL_Note"];
                $vendor->Vendor_Note_General = $_POST["Vendor_Note_General"];
                $vendor->Active_Relationship = $_POST["Active_Relationship"];
                if ($vendor->validate()) {
                    $vendor->save();
                    echo "vendor\n";
                }

                if ($company->adreses) {
                    $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 "address\n";
                        }
                    }
                }

                $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";
                }
            }
            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $vendorId = intval($_POST["id"]);
            $vendor = Vendors::model()->findByPk($vendorId);
            if ($vendor) {
                $vendor->delete();
            }
            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"] = "Vendor ID"; // caption of column
        $col["name"] = "Vendor_ID";
        $col["dbname"] = "vendors.Vendor_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"] = "Vendor Shortcut"; // caption of column
        $col["name"] = "Vendor_ID_Shortcut";
        $col["dbname"] = "vendors.Vendor_ID_Shortcut"; // 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;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor Checkprint"; // caption of column
        $col["name"] = "Vendor_Name_Checkprint";
        $col["dbname"] = "vendors.Vendor_Name_Checkprint"; // 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;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor 1099"; // caption of column
        $col["name"] = "Vendor_1099";
        $col["dbname"] = "vendors.Vendor_1099"; // 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;
        $col["sortable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $cols[] = $col;

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

        // set columns
        $col = array();
        $col["title"] = "Vendor Default GL"; // caption of column
        $col["name"] = "Vendor_Default_GL";
        $col["dbname"] = "vendors.Vendor_Default_GL"; // 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;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor GL Note"; // caption of column
        $col["name"] = "Vendor_Default_GL_Note";
        $col["dbname"] = "vendors.Vendor_Default_GL_Note"; // 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;
        $col["sortable"] = true;
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Vendor Note General"; // caption of column
        $col["name"] = "Vendor_Note_General";
        $col["dbname"] = "vendors.Vendor_Note_General"; // 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;
        $col["sortable"] = true;
        $col["edittype"] = "textarea";
        $col["editoptions"] = array("cols"=>'20', 'rows' => '3');
        $cols[] = $col;

        // set columns
        $col = array();
        $col["title"] = "Active Relationship"; // caption of column
        $col["name"] = "Active_Relationship";
        $col["dbname"] = "vendors.Active_Relationship"; // 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;
        $col["sortable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>'0:0;1:1');
        $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;

        $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;
        $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"] = "Vendor List";
       // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$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 vendors.*, companies.*, addresses.*
                              FROM vendors
                              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 = "vendors";

        $g->set_columns($cols);

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

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

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #23
0
$col["title"] = "";
$col["name"] = "more_options";
$col["width"] = "48";
$col["align"] = "center";
$col["hidden"] = false;
// $col["editoptions"] = array("value"=>"SKU");
$col["search"] = false;
$col["sortable"] = false;
# no new line in this html, only space. otherwise it may break ui of grid
$too = $row["component_id"];
$button1 = "<button name=\"subject\" onclick=\"return sendText(this);\" type=\"submit\" value=\"{id}\" class=\"btn btn-primary\">Списать</button>";
$button2 = "<a target='_blank' style='text-decoration:none; white-space:none; border:1px solid gray; padding:2px; position:relative; width:25px; color:red'>Списано</a>";
$col["condition"] = array('$row["invdate"] == \'\'', $button1, $button2);
$col["default"] = $button;
$cols2[] = $col;
$g->set_columns($cols2);
$g->set_actions(array("add" => false, "edit" => false, "delete" => false, "rowactions" => true, "export" => false, "autofilter" => false, "search" => "simple"));
// and use in sql for filteration
$g->select_command = "SELECT users.user_id, users.user_login, invlines.id, invlines.amount, invlines.invdate,\n\t\t\t\t\t\t\tComponents_SKU.name, invlines.component_id, Components_SKU.room, Components_SKU.box, Components_SKU.cell FROM invlines \n\t\t\t\t\t\t\tINNER JOIN users ON users.user_id = invlines.user_id  \n\t\t\t\t\t\t\tINNER JOIN Components_SKU ON invlines.component_id = Components_SKU.component_id WHERE users.user_id = {$id}";
## ------------------ ##
## SERVER SIDE EVENTS ##
## ------------------ ##
// params are array(<function-name>,<class-object> or <null-if-global-func>,<continue-default-operation>)
// if you pass last argument as true, functions will act as a data filter, and insert/update will be performed by grid
// $e["on_update"] = array("update_changes", null, false);
// $g->set_events($e);
// Custom UPDATE
function update_changes($data)
{
    // mysql_query("START TRANSACTION");
    // $query1 = mysql_query("UPDATE Components_SKU SET
Пример #24
0
    /**
     * Lists all models.
     */
    public function actionIndex()
    {
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $setID = intval($_POST["id"]);
            $set = ServiceLevelSettings::model()->findByPk($setID);

            if ($set) {
                $set->Tier_Name = $_POST["Tier_Name"] ? $_POST["Tier_Name"] : null;
                $set->Users_Count = $_POST["Users_Count"] ? $_POST["Users_Count"] : null;
                $set->Projects_Count = $_POST["Projects_Count"] ? $_POST["Projects_Count"] : null;
                $set->Storage_Count = $_POST["Storage_Count"] ? $_POST["Storage_Count"] : null;
                $set->Base_Fee = $_POST["Base_Fee"] ? $_POST["Base_Fee"] : null;
                $set->Additional_User_Fee = $_POST["Additional_User_Fee"] ? $_POST["Additional_User_Fee"] : null;
                $set->Additional_Project_Fee = $_POST["Additional_Project_Fee"] ? $_POST["Additional_Project_Fee"] : null;
                $set->Additional_Storage_Fee = $_POST["Additional_Storage_Fee"] ? $_POST["Additional_Storage_Fee"] : null;
                $set->Trial_Period = $_POST["Trial_Period"] ? $_POST["Trial_Period"] : null;
                $set->Description = $_POST["Description"] ? $_POST["Description"] : null;
                if ($set->validate()) {
                    $set->save();
                    echo "settings\n";
                }
            }

            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            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"] = "Service Level ID"; // caption of column
        $col["name"] = "Service_Level_ID";
        $col["dbname"] = "Service_Level_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"] = true;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Tier Name"; // caption of column
        $col["name"] = "Tier_Name";
        $col["dbname"] = "Tier_Name"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Users Count"; // caption of column
        $col["name"] = "Users_Count";
        $col["dbname"] = "Users_Count"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Projects Count"; // caption of column
        $col["name"] = "Projects_Count";
        $col["dbname"] = "Projects_Count"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Storage Count"; // caption of column
        $col["name"] = "Storage_Count";
        $col["dbname"] = "Storage_Count"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Base Fee"; // caption of column
        $col["name"] = "Base_Fee";
        $col["dbname"] = "Base_Fee"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Additional User Fee"; // caption of column
        $col["name"] = "Additional_User_Fee";
        $col["dbname"] = "Additional_User_Fee"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Additional Project Fee"; // caption of column
        $col["name"] = "Additional_Project_Fee";
        $col["dbname"] = "Additional_Project_Fee"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Additional Storage Fee"; // caption of column
        $col["name"] = "Additional_Storage_Fee";
        $col["dbname"] = "Additional_Storage_Fee"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Trial_Period"; // caption of column
        $col["name"] = "Trial_Period";
        $col["dbname"] = "Trial_Period"; // 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;
        $cols[] = $col;

        $col = array();
        $col["title"] = "Description"; // caption of column
        $col["name"] = "Description";
        $col["dbname"] = "Description"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["hidden"] = false;
        $col["viewable"] = true;
        $col["search"] = true;
        $col["sortable"] = false;
        $col["edittype"] = "textarea";
        $col["editoptions"] = array("rows"=>15, "cols"=>80);
        $cols[] = $col;


        $g = new jqgrid();

        $grid["caption"] = "Service Level Settings";
        // $grid["multiselect"] = true;
        $grid["autowidth"] = true;
        $grid["resizable"] = true;
        //$grid["toppager"] = true;
        $grid["sortname"] = 'Service_Level_ID';
        $grid["sortorder"] = "ASC";
        $grid["add_options"] = array(
            'width'=>'600',
            "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"=>true, // allow/disallow add
                "edit"=>true, // allow/disallow edit
                "delete"=>false, // 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 service_level_settings.*
                              FROM service_level_settings";

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

        $g->set_columns($cols);

        // group columns header
        $g->set_group_header( array(
                "useColSpanStyle"=>true,
                "groupHeaders"=>array(
                    array(
                        "startColumnName"=>'Service_Level_ID', // group starts from this column
                        "numberOfColumns"=>11, // group span to next 2 columns
                        "titleText"=>'Service Level Settings Information' // caption of group header
                    ),
                )
            )
        );

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

        $this->render('index',array(
            'out'=>$out,
        ));
    }
Пример #25
0
 public function index()
 {
     //check login
     if ($this->session->userdata('user_name')) {
         $i_rule = $this->session->userdata('user_cizacl_role_id');
         $g = new jqgrid();
         #ID
         $col = array();
         $col['title'] = "ID";
         $col['name'] = "customer_id";
         $col['hidden'] = true;
         $col['isnull'] = true;
         $cols[] = $col;
         #Factory
         $col = array();
         $col["title"] = $this->lang->line("factory_name");
         $col["name"] = "factory_id";
         $col["dbname"] = "cus.factory_id";
         // this is required as we need to search in name field, not id
         $col["width"] = "100";
         $col["align"] = "left";
         $col["search"] = true;
         $col["editable"] = true;
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         $str = $g->get_dropdown_values("select distinct factory_id as k, factory_name as v from transport_factory");
         $col["editoptions"] = array("value" => ":;" . $str);
         $col["formatter"] = "select";
         // display label, not value
         $col["editrules"] = array("required" => true);
         $cols[] = $col;
         #Customer_Type
         $col = array();
         $col["title"] = $this->lang->line('customer_type');
         $col["name"] = "customer_type_id";
         $col["dbname"] = "cus_type.customer_type_title";
         // this is required as we need to search in name field, not id
         $col["fixed"] = true;
         //$col["width"] = "65";
         $col["align"] = "left";
         $col["search"] = true;
         $col["editable"] = true;
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         //$str = $g->get_dropdown_values("select distinct client_id as k, name as v from clients");
         $str = $g->get_dropdown_values("SELECT DISTINCT customer_type_id AS k, customer_type_title AS v FROM `transport_customer_type` WHERE customer_type_status ='2'");
         #$str = $this->dropdrown->get_customer_type();
         $col["editoptions"] = array("value" => $str);
         $col["formatter"] = "select";
         // display label, not value
         $cols[] = $col;
         #Customer name
         $col = array();
         $col['title'] = $this->lang->line('customer_agancy');
         $col['name'] = "customers_name";
         $col["editrules"] = array("required" => true);
         $col["search"] = true;
         $col['editable'] = true;
         $cols[] = $col;
         $col = array();
         $col['title'] = $this->lang->line('car_number');
         $col['name'] = "car_id";
         $col['dbname'] = "cus.car_id";
         $col["width"] = "100";
         $col["align"] = "left";
         $col["search"] = true;
         $col["editable"] = true;
         $col["edittype"] = "select";
         // render as select
         # fetch data from database, with alias k for key, v for value
         $str = $g->get_dropdown_values("SELECT DISTINCT car_id AS k,car_number AS v FROM transport_cars;");
         $col["editoptions"] = array("value" => ":;" . $str);
         $col["formatter"] = "select";
         // display label, not value
         $cols[] = $col;
         #remark
         $col = array();
         $col['title'] = $this->lang->line('car_license');
         $col['name'] = "car_license";
         $col['editable'] = true;
         $col['edittype'] = "textarea";
         $col['editoptions'] = array("rows" => "2", "cols" => "20");
         $cols[] = $col;
         #Address
         $col = array();
         $col['title'] = $this->lang->line('Address1');
         $col['name'] = "address1";
         $col['editable'] = true;
         $col["search"] = false;
         $col['edittype'] = "textarea";
         $col['editoptions'] = array("rows" => "2", "cols" => "20");
         $cols[] = $col;
         #Contact Person
         $col = array();
         $col['title'] = $this->lang->line('contact_person');
         $col['name'] = "contact_person";
         $col['editable'] = true;
         $cols[] = $col;
         # Tel
         /*
         $col = array();
         $col['title'] = $this->lang->line('tel');
         $col['name'] = "mobile_number";
         $col['editable'] = true;
         $col["editrules"] = array("number" => true);
         $cols[] = $col;
         */
         #remark
         $col = array();
         $col['title'] = $this->lang->line('note');
         $col['name'] = "remark";
         $col['editable'] = true;
         $col['edittype'] = "textarea";
         $col["viewable"] = false;
         $col['editoptions'] = array("rows" => "2", "cols" => "20");
         $cols[] = $col;
         $e["on_insert"] = array("add_client", null, true);
         #$e["on_delete"] = array("del_client", null, true);
         $g->set_events($e);
         $g->select_command = "SELECT\n\tcustomer_id,\n\tcus.customer_type_id,\n\tcus_type.customer_type_title,\n\tcus.factory_id,\n\tcustomers_name,\n\tcus.car_id,\n\tcus.car_license,\n\taddress1,\n\tcontact_person,\n\tmobile_number,\n\tremark\nFROM\n\ttransport_customers AS cus\nLEFT JOIN transport_factory AS fac ON (\n\tcus.factory_id = fac.factory_id\n)\nLEFT JOIN transport_customer_type AS cus_type ON (\n\tcus.customer_type_id = cus_type.customer_type_id\n)\nLEFT JOIN transport_cars AS car ON (cus.car_id=car.car_id)\nWHERE\n\tcus. STATUS = 1\nAND cus_type.customer_type_status != 1";
         function add_client(&$data)
         {
             $check_sql = "SELECT count(*) as c from transport_customers where LOWER(`customers_name`) = '" . strtolower($data["params"]["customers_name"]) . "'";
             $rs = mysql_fetch_assoc(mysql_query($check_sql));
             if ($rs["c"] > 0) {
                 phpgrid_error("ข้อมูลลูกค้าซ้ำ");
             }
         }
         // end of sub function
         function del_client(&$data)
         {
             $check_sql = "UPDATE `transport_customers` SET `status`='0' WHERE (`customer_id`='{$data["id"]}')";
             mysql_query($check_sql);
         }
         //Use Table
         $g->table = "transport_customers";
         // pass the cooked columns to grid
         $g->set_columns($cols);
         $opt["sortname"] = 'customer_id';
         $opt["sortorder"] = "desc";
         $opt["rowList"] = array(10, 20, 30);
         $opt["caption"] = $this->lang->line('customer');
         $opt["autowidth"] = true;
         $opt["multiselect"] = false;
         $opt["autowidth"] = true;
         $opt["view_options"]['width'] = '520';
         $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt["edit_options"]["beforeSubmit"] = "function(post,form){ return validate_form_once(post,form); }";
         $g->set_options($opt);
         $g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'customer', 'add_customer'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'customer', 'edit_customer'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'customer', 'del_customer'), "export" => false, "autofilter" => true, "search" => "advance"));
         // set database table for CRUD operations
         // render grid and get html/js output
         $out_index = $g->render("list1");
         $h2_title = $this->lang->line('customeroils');
         //display
         $this->_example_output((object) array('output' => '', 'out' => $out_index, 'h2_title' => $h2_title, 'js_files' => array(), 'css_files' => array()));
     } else {
         //If no session, redirect to login page
         redirect('login', 'refresh');
     }
 }
Пример #26
0
 public function index()
 {
     if ($this->session->userdata('user_name')) {
         $i_rule = $this->session->userdata('user_cizacl_role_id');
         $this->load->model('income_model', 'dropdrown');
         $this->load->model('dropdown_model', 'cus_drop');
         $g = new jqgrid();
         $col = array();
         $col["title"] = "Id";
         // caption of column
         $col["name"] = "id";
         $col["width"] = "10";
         $col["fixed"] = true;
         $col["search"] = false;
         $col["editable"] = false;
         $col["export"] = false;
         $col["hidden"] = true;
         $cols[] = $col;
         $col = array();
         $col['title'] = "cubic value";
         $col['name'] = "cubic_id";
         $col['dbname'] = "orders.cubic_id";
         $col["editable"] = true;
         $col["formatter"] = "select";
         $col["editable"] = true;
         $col["edittype"] = "select";
         $str = $g->get_dropdown_values("SELECT DISTINCT cubic_id AS k, cubic_value AS v FROM transport_cubiccode WHERE cubic_status=1");
         //$col["editoptions"] = array("value"=>":;".$str);
         $col["editoptions"] = array("value" => $str);
         $col["formatter"] = "select";
         // display label, not value
         $cols[] = $col;
         /**Option Form */
         $opt["sortname"] = 'id';
         $opt["sortorder"] = "desc";
         $opt["caption"] = $this->lang->line('Order_Transportation');
         $opt['rowNum'] = 10;
         $opt['rowList'] = array(10, 20, 30);
         $opt['height'] = "300";
         $opt["autowidth"] = true;
         $opt["multiselect"] = false;
         $opt["scroll"] = true;
         $opt["add_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt["edit_options"] = array("recreateForm" => true, "closeAfterEdit" => true, 'width' => '420');
         $opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#dp_number").focus(); }';
         $opt["altRows"] = true;
         $opt["altclass"] = "myAltRowClass";
         $g->set_options($opt);
         $g->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'add'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'edit'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'truckorder', 'delete'), "rowactions" => true, "export" => true, "autofilter" => true, "search" => "advance"));
         $g->select_command = "SELECT\n\tid,\n\tdp_number,\n\torders.customer_id,\n    cus.customers_name AS cid,\n    orders.factory_id,\n\tfac.factory_code,\n\treal_distance,\n\torders.distance_id,\n\tdis.distance_code,\n\torders.cubic_id,\n    cubic.cubic_value,\n    orders.price AS price,\n\torders.use_oil,\n    orders.car_id,\n\tcar.car_number,\n\torders.driver_id,\n\tdri.driver_name,\n    order_date,\n    orders.delivery_datetime,\n    orders.remark\n\nFROM\n\t`orders` AS orders\nLEFT JOIN transport_factory AS fac ON (\n\torders.factory_id = fac.factory_id\n)\nLEFT JOIN transport_customers AS cus ON (\n\torders.customer_id = cus.customer_id\n)\nLEFT JOIN transport_cubiccode AS cubic ON (\n\torders.cubic_id = cubic.cubic_id\n)\nLEFT JOIN distancecode AS dis ON (\n\torders.distance_id = dis.distance_id\n)\nLEFT JOIN transport_cars AS car ON (\norders.car_id = car.car_id\n)\nLEFT JOIN driver AS dri ON (\n\torders.driver_id = dri.driver_id\n)";
         // this db table will be used for add,edit,delete
         $g->table = "orders";
         $e["on_after_insert"] = array("after_insert", null, true);
         $e["on_update"] = array("do_update", null, true);
         /*      
         $e["on_insert"] = array(
             "add_order",
             null,
             true);
         */
         $e["on_data_display"] = array("filter_display", null, true);
         $g->set_events($e);
         function add_order(&$data)
         {
             //print_r($data);
             $obj =& get_instance();
             $obj->load->model("price_model", "pricelist");
             //$id = intval($_REQUEST["id"]);
             $factory_id = $data["params"]["factory_id"];
             $distance_id = $data["params"]["distance_id"];
             $cubid_id = $data["params"]["cubic_id"];
             $order_date = $data["params"]["order_date"];
             #get price
             $order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
             if ($order_price == null) {
                 $str = ob_get_clean();
                 $str = "ไม่มีการกำหนดราคาค่าขนส่ง";
                 phpgrid_error($str);
             }
             /*check DP NUmber*/
             $check_sql = "SELECT count(*) as c from orders where LOWER(`dp_number`) = '" . strtolower($data["params"]["dp_number"]) . "'";
             $rs = mysql_fetch_assoc(mysql_query($check_sql));
             if ($rs["c"] > 0) {
                 phpgrid_error("หมายเลข DP Number ซ้ำ");
             }
             /*End Check DP Number*/
             //$str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
             //mysql_query($str);
         }
         function do_update(&$data)
         {
             //print_r($data);
             $obj =& get_instance();
             $obj->load->model("price_model", "pricelist");
             $id = intval($_REQUEST["id"]);
             $factory_id = $data["params"]["factory_id"];
             $distance_id = $data["params"]["distance_id"];
             $cubid_id = $data["params"]["cubic_id"];
             $order_date = $data["params"]["order_date"];
             #get price
             $order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
             if ($order_price == null) {
                 $str = ob_get_clean();
                 $str = "ไม่มีการกำหนดราคาค่าขนส่ง";
                 phpgrid_error($str);
             } else {
                 $data["params"]["price"] = $order_price;
                 $str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
                 mysql_query($str);
             }
             //$str = "UPDATE orders SET price ='{$data["parmas"]["price"]}' WHERE id = '{$data["id"]}'";
             //mysql_query($str);
         }
         function after_insert(&$data)
         {
             //print_r($data);
             $obj =& get_instance();
             $obj->load->model("price_model", "pricelist");
             $id = $data["id"];
             $factory_id = $data["params"]["factory_id"];
             $distance_id = $data["params"]["distance_id"];
             $cubid_id = $data["params"]["cubic_id"];
             $order_date = $data["params"]["order_date"];
             #get price
             $order_price = $obj->pricelist->get_order_Price($factory_id, $cubid_id, $distance_id, $order_date);
             $str = "UPDATE orders SET price ='{$order_price}' \n                    WHERE id = {$data["id"]}";
             mysql_query($str);
         }
         function filter_display($data)
         {
             foreach ($data["params"] as &$d) {
                 foreach ($d as $k => $v) {
                     $d[$k] = strtoupper($d[$k]);
                 }
             }
         }
         // pass the cooked columns to grid
         $g->set_columns($cols);
         // generate grid output, with unique grid name as 'list1'
         $out = $g->render("list1");
         $iprice = $this->price->get_order_Price(2, 2, 2);
         //display
         $this->_example_output((object) array('output' => "", 'out' => $out, 'iprice' => $iprice, 'js_files' => array(), 'css_files' => array()));
         //$this->_example_output();
     } else {
         redirect('login', 'refresh');
     }
     //end if
 }
Пример #27
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,
        ));
	}
Пример #28
0
 public function index()
 {
     //check login
     if ($this->session->userdata('user_name')) {
         $i_rule = $this->session->userdata('user_cizacl_role_id');
         if ($this->cizacl->check_isAllowed($i_rule, 'income')) {
             $g = new jqgrid();
             $opt["caption"] = $this->lang->line('factory');
             $opt["detail_grid_id"] = "list2";
             $opt['autowidth'] = true;
             $opt['height'] = "60";
             // extra params passed to detail grid, column name comma separated
             //$opt["subgridparams"] = "client_id,gender,company";
             $opt["subgridparams"] = "factory_id,factory_code,factory_name";
             $opt["export"]["range"] = "filtered";
             $g->set_options($opt);
             $g->table = "transport_factory";
             $col = array();
             $col["title"] = $this->lang->line('id');
             // caption of column
             $col["name"] = "factory_id";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "10";
             $col['hidden'] = true;
             $col["editable"] = false;
             $cols[] = $col;
             $col = array();
             $col['title'] = $this->lang->line('factory_code');
             $col['name'] = "factory_code";
             $col["editable"] = false;
             $cols[] = $col;
             $col = array();
             $col['title'] = $this->lang->line('factory_name');
             $col['name'] = "factory_name";
             //$col["width"] = "10";
             $col["editable"] = false;
             $cols[] = $col;
             $g->set_columns($cols);
             $g->set_actions(array("add" => false, "edit" => false, "delete" => false, "rowactions" => false, "autofilter" => false, "search" => "advance"));
             $out_master = $g->render("list1");
             // detail grid
             $grid = new jqgrid();
             $opt = array();
             $opt["sortname"] = 'id';
             // by default sort grid by this field
             $opt["sortorder"] = "desc";
             // ASC or DESC
             $opt["height"] = 300;
             // autofit height of subgrid
             $opt["rowNum"] = 10;
             // by default 20
             $opt['rowList'] = array(10, 20, 30, 100, 1000);
             $opt["autowidth"] = true;
             $opt['form']['position'] = "left";
             $opt['form']['nav'] = true;
             $opt["caption"] = $this->lang->line('expense_list');
             // caption of grid
             $opt["multiselect"] = false;
             // allow you to multi-select through checkboxes
             //footer
             $opt["footerrow"] = true;
             $opt["reloadedit"] = true;
             // Check if master record is selected before detail addition
             $opt["add_options"]["beforeInitData"] = "function(formid){ var selr = jQuery('#list1').jqGrid('getGridParam','selrow'); if (!selr) { alert('Please select master record first'); return false; } }";
             $opt["add_options"]["afterShowForm"] = 'function(formid) { jQuery("#ref_number").focus(); }';
             // excel visual params
             // $opt["cellEdit"] = true; // inline cell editing, like spreadsheet
             $opt["rownumbers"] = true;
             $opt["rownumWidth"] = 30;
             $grid->set_options($opt);
             // disable all dialogs except edit
             $grid->navgrid["param"]["edit"] = false;
             $grid->navgrid["param"]["add"] = false;
             $grid->navgrid["param"]["del"] = false;
             $grid->navgrid["param"]["search"] = false;
             $grid->navgrid["param"]["refresh"] = true;
             $grid->set_actions(array("add" => $this->cizacl->check_isAllowed($i_rule, 'expense', 'add_expense'), "edit" => $this->cizacl->check_isAllowed($i_rule, 'expense', 'edit_expense'), "delete" => $this->cizacl->check_isAllowed($i_rule, 'expense', 'del_expense'), "rowactions" => true, "export" => false, "autofilter" => true, "search" => "advance"));
             // enable inline editing buttons
             $grid->set_actions(array("inline" => true, "rowactions" => true));
             // set database table for CRUD operations
             if (!empty($_REQUEST)) {
                 $id = intval($_GET["rowid"]);
                 $factory_code = $_GET["factory_code"];
                 $company = $_GET["factory_name"];
                 $cid = intval($_GET["factory_id"]);
                 $this->session->set_userdata('facs_id', $cid);
             }
             $fac_id = $this->session->userdata('facs_id');
             // for non-int fields as PK
             // $id = (empty($_GET["rowid"])?0:$_GET["rowid"]);
             // and use in sql for filteration
             //$grid->select_command = "SELECT id,client_id,invdate,amount,tax,total,'$company' as 'company' FROM invheader WHERE client_id = $cid";
             //$grid->select_command = "SELECT id,income_date,factory_id,ref_number,total_amount,note FROM `income` WHERE factory_id=$cid";
             //$grid->select_command = "SELECT id,expense_date,factory_id,car_id,ref_number,expense_details,total_amount,	note,(SELECT SUM(total_amount)FROM	expense WHERE factory_id = $cid	) AS sumtotals FROM	`expense`WHERE	factory_id = $cid";
             // this db table will be used for add,edit,delete
             $grid->select_command = "SELECT\n\tid,\n\texpense_date,\n\tfactory_id,\n\texpense.car_id,\n\tcar_number,\n\tref_number,\n\texpense_details,\n\ttotal_amount,\n\texpense.note,\n\t(\n\t\tSELECT\n\t\t\tSUM(total_amount)\n\t\tFROM\n\t\t\texpense\n\t\tWHERE\n\t\t\tfactory_id = {$fac_id}\n\t) AS sumtotals\nFROM\n\t`expense`\nLEFT JOIN transport_cars ON(expense.car_id=transport_cars.car_id)\nWHERE\n\tfactory_id = {$fac_id} AND expense.car_id=0";
             //$grid->table = "invheader";
             $grid->table = "expense";
             #ID
             $col = array();
             $col["title"] = $this->lang->line('id');
             // caption of column
             $col["name"] = "id";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "30";
             $col['hidden'] = true;
             $cols2[] = $col;
             #Expanse date
             $col = array();
             $col["title"] = $this->lang->line('date');
             $col["name"] = "expense_date";
             $col["width"] = "20";
             $col["editable"] = true;
             // this column is editable
             //$col["editoptions"] = array("size" => 20, "defaultValue" => date('d-m-Y')); // with default display of textbox with size 20
             $col["editoptions"] = array("size" => 20);
             // with default display of textbox with size 20
             $col["editrules"] = array("required" => true);
             // and is required
             # format as date
             $col["formatter"] = "date";
             # opts array can have these options: http://api.jqueryui.com/datepicker/
             $col["formatoptions"] = array("srcformat" => 'Y-m-d', "newformat" => 'd-m-Y', "opts" => array("changeYear" => false));
             $cols2[] = $col;
             /*
             $col = array();
             $col["title"] = $this->lang->line('reference_number'); // caption of column
             $col["name"] = "ref_number"; // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "30";
             $col["editable"] = true;
             $cols2[] = $col;
             */
             # Descriptionns
             $col = array();
             $col["title"] = $this->lang->line('desc');
             // caption of column
             $col["name"] = "expense_details";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "100";
             $col['edittype'] = "textarea";
             $col['editoptions'] = array("rows" => '2', "cols" => '60');
             $col["editrules"] = array("required" => true);
             #$col["formatter"] = "autocomplete"; // autocomplete
             /*
             $col["formatoptions"] = array(
             "sql" => "SELECT DISTINCT expense_details as k, expense_details as v FROM expense",
             "search_on" => "expense_details",
             "update_field" => "expense_details");
             */
             $col["editable"] = true;
             $cols2[] = $col;
             $col = array();
             $col["title"] = $this->lang->line('amount');
             $col["name"] = "total_amount";
             $col["width"] = "30";
             $col['align'] = "right";
             $col['formatter'] = "currency";
             $col["formatoptions"] = array("prefix" => "", "suffix" => '', "thousandsSeparator" => ",", "decimalSeparator" => ".", "decimalPlaces" => '2');
             $col["editable"] = true;
             // this column is editable
             $col["editoptions"] = array("size" => 20);
             // with default display of textbox with size 20
             $col["editrules"] = array("required" => true, "number" => true);
             // and is required
             $cols2[] = $col;
             #Not Remarl
             $col = array();
             $col["title"] = $this->lang->line('note');
             // caption of column
             $col["name"] = "note";
             // field name, must be exactly same as with SQL prefix or db field
             $col["width"] = "40";
             $col['edittype'] = "textarea";
             $col['editoptions'] = array("rows" => '2', "cols" => '20');
             $col["editable"] = true;
             /*
             $col["formatter"] = "autocomplete"; // autocomplete
             $col["formatoptions"] = array(
             "sql" => "SELECT DISTINCT note as k, note as v FROM expense",
             "search_on" => "note",
             "update_field" => "note");
             */
             $cols2[] = $col;
             $grid->set_columns($cols2);
             $e["js_on_load_complete"] = "grid2_onload";
             $e["on_insert"] = array("add_client", null, true);
             $grid->set_events($e);
             function add_client(&$data)
             {
                 $id = intval($_GET["rowid"]);
                 $data["params"]["factory_id"] = $id;
                 $data["params"]["car_id"] = 0;
             }
             // generate grid output, with unique grid name as 'list1'
             $out_detail = $grid->render("list2");
             // Head Title
             $h2_title = $this->lang->line('expense');
             $this->_example_output((object) array('output' => '', 'out_detail' => $out_detail, 'out_master' => $out_master, 'js_files' => array(), 'css_files' => array(), 'h2_title' => $h2_title));
         } else {
             $this->_example_output();
         }
         //end if
     } else {
         redirect('login', 'refresh');
     }
 }
$col["title"] = "Módulo 05";
// caption of column
$col["name"] = "n23";
// grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["editable"] = true;
$col["editoptions"] = array("defaultValue" => "Default Company");
$cols[] = $col;
$col = array();
$col["title"] = "Módulo 06";
// caption of column
$col["name"] = "n24";
// grid column name, must be exactly same as returned column-name from sql (tablefield or field-alias)
$col["editable"] = true;
$col["editoptions"] = array("defaultValue" => "Default Company");
$cols[] = $col;
$g->set_columns($cols);
$g->set_actions(array("add" => true, "edit" => true, "delete" => false, "clone" => true, "rowactions" => true, "search" => "advance", "showhidecolumns" => false));
// render grid
$out = $g->render("list1");
$themes = array("black-tie", "blitzer", "cupertino", "dark-hive", "dot-luv", "eggplant", "excite-bike", "flick", "hot-sneaks", "humanity", "le-frog", "mint-choc", "overcast", "pepper-grinder", "redmond", "smoothness", "south-street", "start", "sunny", "swanky-purse", "trontastic", "ui-darkness", "ui-lightness", "vader");
$i = rand(0, 8);
// if set from page
if (is_numeric($_GET["themeid"])) {
    $i = $_GET["themeid"];
} else {
    $i = 14;
}
?>
<!DOCTYPE html>
<html lang="en">
  <head>
Пример #30
0
$col = array();
$col["title"] = "Mode de paiement";
$col["name"] = "ModePaiement";
$col["width"] = "50";
$col["editable"] = true;
// this column is editable
$col["editoptions"] = array("size" => 20);
// with default display of textbox with size 20
$col["editrules"] = array("required" => true);
// and is required
$cols[] = $col;
$detail_grid->select_command = "SELECT NoVente, PoidsAchat, t_detail.IDClient, PrixKgTTC, ModePaiement FROM t_detail\n                        INNER JOIN t_clients on t_clients.ID = t_detail.IDClient ";
// this db table will be used for add,edit,delete
$detail_grid->table = "t_detail";
// pass the cooked columns to grid
$detail_grid->set_columns($cols);
// generate grid output, with unique grid name as 'list1'
$out = $detail_grid->render("detail");
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
    <link rel="stylesheet" type="text/css" media="screen" href="lib/js/themes/redmond/jquery-ui.custom.css"></link>
    <link rel="stylesheet" type="text/css" media="screen" href="lib/js/jqgrid/css/ui.jqgrid.css"></link>

    <script src="lib/js/jquery.min.js" type="text/javascript"></script>
    <script src="lib/js/jqgrid/js/i18n/grid.locale-en.js" type="text/javascript"></script>
    <script src="lib/js/jqgrid/js/jquery.jqGrid.min.js" type="text/javascript"></script>
    <script src="lib/js/themes/jquery-ui.custom.min.js" type="text/javascript"></script>
</head>
<body>