/** * 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, )); }
/** * 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, )); }
/** * 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, )); }
/** * 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, )); }
/** * 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, )); }
$grid["subGrid"] = true; $grid["subgridurl"] = "subgrid_sub_detail.php"; // $grid["subgridparams"] = "closed"; // extra data for sub grid // $grid["cellEdit"] = true; // to refresh parent after subgrid edit // $grid["afterSubmitCell"] = "function(serverresponse, rowid, cellname, value, iRow, iCol) { jQuery('#list1').trigger('reloadGrid',[{jqgrid_page:1}]); return [true, '']; }"; $g->set_options($grid); $g->set_actions(array("add" => true, "edit" => true, "delete" => true, "rowactions" => true, "export" => true, "autofilter" => true, "search" => "advance")); // you can provide custom SQL query to display data $g->select_command = "select i.id, i.client_id, i.invdate, c.name,\n\t\t\t\t\t\ti.note, i.total, i.closed FROM invheader i\n\t\t\t\t\t\tINNER JOIN clients c ON c.client_id = i.client_id\n\t\t\t\t\t\tWHERE c.client_id = {$c_id}"; // this db table will be used for add,edit,delete $g->table = "invheader"; // pass the cooked columns to grid $g->set_columns($cols); // group columns header $g->set_group_header(array("useColSpanStyle" => true, "groupHeaders" => array(array("startColumnName" => 'invdate', "numberOfColumns" => 2, "titleText" => 'Company Details')))); // generate grid output, with unique grid name as 'list1' $out = $g->render("sub1"); echo $out; ?> <script> jQuery(document).ready(function(){ jQuery('#<?php echo $g->id; ?> ').jqGrid('navButtonAdd', '#<?php echo $g->id; ?> _pager', { 'caption' : 'Custom Button',
/** * 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, )); }
/** * 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, )); }
/** * 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, )); }
/** * 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, )); }
/** * 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, )); }
/** * 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, )); }
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'); } }
/** * Lists all models. */ public function actionIndex() { if (isset($_POST['oper']) && $_POST['oper'] == 'edit') { $ids = explode(',', $_POST["id"]); $userId = $ids[0]; $clientId = $ids[1]; if (is_numeric($userId) && is_numeric($clientId)) { $userClientRow = UsersClientList::model()->with('client', 'user')->findByAttributes(array( 'User_ID' => $userId, 'Client_ID' => $clientId, )); if ($userClientRow) { $client = $userClientRow->client; $company = $client->company; $user = $userClientRow->user; $person = $user->person; $addresses = $company->adreses; $userClientRow->User_Type = $_POST["User_Type"]; $userClientRow->User_Approval_Value = intval($_POST["User_Approval_Value"]); if ($userClientRow->validate()) { $userClientRow->save(); echo "UsersClientList\n"; } 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"]; if ($company->validate()) { $company->save(); echo "company\n"; } } $user->User_Login = $_POST["User_Login"]; $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"; } } } die; } if (isset($_POST['oper']) && $_POST['oper'] == 'add') { die; } if (isset($_POST['oper']) && $_POST['oper'] == 'del') { $ids = explode(',', $_POST["id"]); $userId = $ids[0]; $clientId = $ids[1]; if (is_numeric($userId) && is_numeric($clientId)) { $userClientRow = UsersClientList::model()->with('client', 'user')->findByAttributes(array( 'User_ID' => $userId, 'Client_ID' => $clientId, )); if ($userClientRow) { $userClientRow->delete(); UsersProjectList::model()->deleteAllByAttributes(array( 'User_ID' => $userId, 'Client_ID' => $clientId, )); } } 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"] = "Joined Key (User_ID, Client_ID)"; // caption of column $col["name"] = "joined_key"; $col["dbname"] = "joined_key"; // 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 Type"; // caption of column $col["name"] = "User_Type"; $col["dbname"] = "users_client_list.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;Approver:Approver;Processor:Processor;Client Admin:Client Admin'); $cols[] = $col; $approvalValues = array(); for ($i = 0; $i <= 100; $i++) { $approvalValues[] = $i . ':' . $i; } $col = array(); $col["title"] = "User Approval Value"; // caption of column $col["name"] = "User_Approval_Value"; $col["dbname"] = "users_client_list.User_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"] = false; $col["sortable"] = true; $col["edittype"] = "select"; $col["editoptions"] = array("value"=>implode(';', $approvalValues)); $cols[] = $col; // set columns $col = array(); $col["title"] = "User ID"; // caption of column $col["name"] = "User_ID"; $col["dbname"] = "users.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"] = "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"] = "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"] = "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; // 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"] = "Client/User List"; // $grid["multiselect"] = true; $grid["autowidth"] = true; $grid["resizable"] = true; //$grid["toppager"] = true; $grid["sortname"] = 'users.User_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 concat(users_client_list.User_ID, ',', users_client_list.Client_ID) as joined_key, users_client_list.User_Type, users_client_list.User_Approval_Value, companies.Company_Name, companies.Company_ID, addresses.*, persons.*, users.User_ID, users.Default_Project, users.User_Login, users.Last_Login, users.Active, users.Last_IP FROM users_client_list LEFT JOIN clients ON clients.Client_ID = users_client_list.Client_ID LEFT JOIN companies ON clients.Company_ID = companies.Company_ID LEFT JOIN users ON users.User_ID = users_client_list.User_ID LEFT JOIN persons ON users.Person_ID = persons.Person_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 = "users_client_list"; $g->set_columns($cols); // group columns header $g->set_group_header( array( "useColSpanStyle"=>true, "groupHeaders"=>array( array( "startColumnName"=>'User_Type', // group starts from this column "numberOfColumns"=>2, // group span to next 2 columns "titleText"=>'User-Client Rel.' // caption of group header ), array( "startColumnName"=>'User_ID', // group starts from this column "numberOfColumns"=>5, // 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"=>'Company_ID', // group starts from this column "numberOfColumns"=>2, // 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("Client_User_List"); $this->render('index',array( 'out'=>$out, )); }
/** * Lists all models. */ public function actionIndex() { if (isset($_POST['oper']) && $_POST['oper'] == 'edit') { $id = intval($_POST["id"]); $rps = RemoteProcessingSettings::model()->findByPk($id); if ($rps) { $error_string= ''; $rps->PerPageFee =$_POST['PerPageFee'] ? $_POST["PerPageFee"] : null; $rps->PerSecondFee =$_POST['PerSecondFee'] ? $_POST["PerSecondFee"] : null; $rps->PaperPageFee =$_POST['PaperPageFee'] ? $_POST["PaperPageFee"] : null; $rps->PerMBFee =$_POST['PerMBFee'] ? $_POST["PerMBFee"] : null; $rps->SetupCharge =$_POST['SetupCharge'] ? $_POST["SetupCharge"] : null; if ($rps->validate() && $error_string == '') { $rps->save(); } else { die($error_string); } } 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"] = "rps_id"; // caption of column $col["name"] = "rps_id"; $col["dbname"] = "rps_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"] = "SetupCharge"; // caption of column $col["name"] = "SetupCharge"; $col["dbname"] = "SetupCharge"; // 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"] = false; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "PerPageFee"; // caption of column $col["name"] = "PerPageFee"; $col["dbname"] = "PerPageFee"; // 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"] = false; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "PerSecondFee"; // caption of column $col["name"] = "PerSecondFee"; $col["dbname"] = "PerSecondFee"; // 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"] = "PerMBFee"; // caption of column $col["name"] = "PerMBFee"; $col["dbname"] = "PerMBFee"; // 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"] = false; $col["sortable"] = true; $cols[] = $col; // set columns $col = array(); $col["title"] = "PaperPageFee"; // caption of column $col["name"] = "PaperPageFee"; $col["dbname"] = "PaperPageFee"; // 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"] = false; $col["sortable"] = true; $cols[] = $col; $g = new jqgrid(); $grid["caption"] = "RP settings"; // $grid["multiselect"] = true; $grid["autowidth"] = true; $grid["resizable"] = true; //$grid["toppager"] = true; $grid["sortname"] = 'RPS_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 remote_processing_settings.* FROM remote_processing_settings"; // set database table for CRUD operations $g->table = "remote_processing_settings"; $g->set_columns($cols); // group columns header $g->set_group_header( array( "useColSpanStyle"=>true, "groupHeaders"=>array( array( "startColumnName"=>'PerPageFee', // group starts from this column "numberOfColumns"=>4, // group span to next 2 columns "titleText"=>'Remote processing Settings' // caption of group header ), ) ) ); // render grid and get html/js output $out = $g->render("Rpsettings"); $this->render('index',array( 'out'=>$out, )); }