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

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

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

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

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

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

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

            die;
        }

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

        if (isset($_POST['oper']) && $_POST['oper'] == 'del') {
            $documentId = intval($_POST["id"]);
            $document = Documents::model()->findByPk($documentId);
            if ($document) {
                Documents::deleteDocument($documentId);
            }
            die;
        }

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

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

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

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

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

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

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

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

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

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

        $col = array();
        $col["title"] = "User Type"; // caption of column
        $col["name"] = "User_Type";
        $col["dbname"] = "users.User_Type"; // grid column name, same as db field or alias from sql
        $col["resizable"] = true;
        $col["editable"] = true; // this column is editable
        $col["viewable"] = true;
        $col["edittype"] = "select";
        $col["editoptions"] = array("value"=>'User:User;Admin:Admin;DB Admin:DB Admin;Data Entry Clerk:Data Entry Clerk');
        $cols[] = $col;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        $g = new jqgrid();

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

        $g->set_options($grid);

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

        $g->select_command = "SELECT   addresses.*, persons.*, users.Default_Project,
                                       users.User_Login, users.User_Type, users.Last_Login, users.Active,
                                       users.Last_IP, documents.*, images.File_Name, images.Mime_Type
                              FROM documents
                              LEFT JOIN images ON images.Document_ID = documents.Document_ID
                              LEFT JOIN users ON users.User_ID = documents.User_ID
                              LEFT JOIN persons ON users.Person_ID = persons.Person_ID
                              LEFT JOIN person_addresses ON person_addresses.Person_ID = persons.Person_ID
                              LEFT JOIN addresses ON addresses.Address_ID = person_addresses.Address_ID";

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

        $g->set_columns($cols);

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

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

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #2
0
 protected function FindLocalPersonByDoc($seria, $number)
 {
     $c = new CDbCriteria();
     if (!(trim($seria) === "")) {
         $c->compare("Series", trim($seria));
     }
     if (!(trim($number) === "")) {
         $c->compare("Numbers", trim($number));
     }
     $models = Documents::model()->findAll($c);
     if (!is_array($models) && is_object($models)) {
         return $models->PersonID;
     }
     foreach ($models as $obj) {
         return $obj->PersonID;
         if ($obj->TypeID == 2) {
             return $obj->PersonID;
         }
         if ($obj->TypeID == 3) {
             return $obj->PersonID;
         }
         if ($obj->TypeID == 4) {
             return $obj->PersonID;
         }
     }
     return 0;
 }
Пример #3
0
 public function loadDocumentsModel($id)
 {
     $model = Documents::model()->findByPk($id);
     if ($model === null) {
         throw new CHttpException(404, 'The requested page does not exist.');
     }
     return $model;
 }
Пример #4
0
 /**
 	 public function run()
 	 {
 		 // list of valid extensions, ex. array("jpeg", "xml", "bmp")
 		 $allowedExtensions = array("jpg");
 		 // max file size in bytes
 		 $sizeLimit = 1 * 1024 * 1024;
 	
 		 $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
 		 $result = $uploader->handleUpload('upload/');
 		 // to pass data through iframe you will need to encode all html tags
 		 $result=htmlspecialchars(json_encode($result), ENT_NOQUOTES);
 		 echo $result;
 	 }
 	 **/
 public function run()
 {
     $folder = Documents::model()->getTempFolderPath();
     $allowedExtensions = array("jpg", "png");
     //array("jpg","jpeg","gif","exe","mov" and etc...
     $sizeLimit = 5 * 1024 * 1024;
     // maximum file size in bytes
     // perform upload
     $uploader = new qqFileUploader($allowedExtensions, $sizeLimit);
     $result = $uploader->handleUpload($folder);
     $return = htmlspecialchars(json_encode($result), ENT_NOQUOTES);
     $fileSize = filesize($folder . $result['filename']);
     //GETTING FILE SIZE
     $fileName = $result['filename'];
     //GETTING FILE NAME
     echo $return;
     // it's array
 }
Пример #5
0
 public static function ZNODropDown($PersonID, $SepcialityID = 0, $Level = 0)
 {
     $res = array("" => "");
     $model = Documents::model()->findAll("PersonID = :PersonID and TypeID = 4", array(":PersonID" => $PersonID));
     if ($SepcialityID != 0) {
         $ssubj = Specialitysubjects::model()->findAll("SpecialityID=:SpecialityID and LevelID = :LevelID", array(":SpecialityID" => $SepcialityID, ":LevelID" => $Level));
         //debug(print_r($ssubj,true));
         if (!empty($model)) {
             foreach ($model as $zno) {
                 //$res[$zno->idDocuments] = $zno->Numbers;
                 if (!empty($zno->subjects)) {
                     foreach ($zno->subjects as $subject) {
                         if (!empty($ssubj)) {
                             //debug('$ssubj->SubjectID='.$ssubj->SubjectID);
                             foreach ($ssubj as $rec) {
                                 if ($subject->subject->idSubjects == $rec->SubjectID) {
                                     //debug('$ssubj->SubjectID='.$ssubj->SubjectID);
                                     $res[$subject->idDocumentSubject] = $subject->subject->SubjectName . ": " . $subject->SubjectValue . " (№" . $zno->Numbers . " от " . $subject->DateGet . ", пін: " . $zno->ZNOPin . ")";
                                 }
                             }
                         } else {
                             $res[$subject->idDocumentSubject] = $subject->subject->SubjectName . ": " . $subject->SubjectValue . " (№" . $zno->Numbers . " от " . $subject->DateGet . ", пін: " . $zno->ZNOPin . ")";
                         }
                     }
                 }
             }
         }
     } else {
         if (!empty($model)) {
             foreach ($model as $zno) {
                 //$res[$zno->idDocuments] = $zno->Numbers;
                 if (!empty($zno->subjects)) {
                     foreach ($zno->subjects as $subject) {
                         $res[$subject->idDocumentSubject] = $subject->subject->SubjectName . ": " . $subject->SubjectValue . " (№" . $zno->Numbers . " от " . $subject->DateGet . ", пін: " . $zno->ZNOPin . ")";
                     }
                 }
             }
         }
     }
     if (count($res) == 2) {
         unset($res[""]);
     }
     return $res;
 }
Пример #6
0
 /**
  * DropDownMask
  * @param type $FacultetID
  * @param type $EducationFormID
  * @param type $QualificationID
  * @param type $BaseSpecID
  * @return string
  */
 public static function DropDownMask($FacultetID = 0, $EducationFormID = 0, $QualificationID = 0, $BaseSpecID = 0)
 {
     $user = Yii::app()->user->getUserModel();
     $records = array();
     $res = array();
     $mask = "";
     if ($QualificationID == 3) {
         $mask = "7";
     }
     if ($QualificationID == 2) {
         $mask = "8";
     }
     if ($QualificationID == 1) {
         $mask = "6";
     }
     if ($FacultetID == 0 || $EducationFormID == 0 || $QualificationID == 0) {
         //$records = Specialities::model()->findAll("SpecialityClasifierCode like '7%' or SpecialityClasifierCode like '8%'");
     } else {
         $records = Specialities::model()->findAll("FacultetID = :FacultetID and PersonEducationFormID = :EducationFormID and SpecialityClasifierCode like '{$mask}%'", array(":FacultetID" => $FacultetID, ":EducationFormID" => $EducationFormID));
     }
     $bs = array();
     if ($BaseSpecID > 0) {
         $doc = Documents::model()->findByPk($BaseSpecID);
         if (!empty($doc->PersonBaseSpecealityID)) {
             $rel = BasespecialityRelation::model()->findAll("PersonBaseSpecialityID = {$doc->PersonBaseSpecealityID}");
             foreach ($rel as $item) {
                 $bs[] = $item->SpecialityID;
             }
         }
     }
     //Yii::log(print_r($BaseSpecID,1));
     //Yii::log(print_r($bs,1));
     foreach ($records as $record) {
         if (!empty($bs)) {
             if (in_array($record->idSpeciality, $bs)) {
                 $res[$record->idSpeciality] = (!empty($record->SpecialityName) ? $record->SpecialityName . " " : "") . $record->SpecialityDirectionName . (!empty($record->SpecialitySpecializationName) ? ": " . $record->SpecialitySpecializationName . " " : "") . "(" . $record->SpecialityClasifierCode . ")";
                 if (!empty($record->PersonEducationFormID)) {
                     switch ($record->PersonEducationFormID) {
                         case "1":
                             $res[$record->idSpeciality] .= "(Д)";
                             break;
                         case "2":
                             $res[$record->idSpeciality] .= "(З)";
                             break;
                         case "3":
                             $res[$record->idSpeciality] .= "(Е)";
                             break;
                     }
                 }
             }
         } else {
             $res[$record->idSpeciality] = (!empty($record->SpecialityName) ? $record->SpecialityName . " " : "") . $record->SpecialityDirectionName . (!empty($record->SpecialitySpecializationName) ? ": " . $record->SpecialitySpecializationName . " " : "") . "(" . $record->SpecialityClasifierCode . ")";
             if (!empty($record->PersonEducationFormID)) {
                 switch ($record->PersonEducationFormID) {
                     case "1":
                         $res[$record->idSpeciality] .= "(Д)";
                         break;
                     case "2":
                         $res[$record->idSpeciality] .= "(З)";
                         break;
                     case "3":
                         $res[$record->idSpeciality] .= "(Е)";
                         break;
                 }
             }
         }
     }
     //Yii::log(print_r($res, 1));
     return $res;
 }
Пример #7
0
 public function findAttachments($comment_id)
 {
     return Documents::model()->findAll(array('condition' => 't.comment_id = :comment_id', 'params' => array('comment_id' => $comment_id), 'order' => 't.document_id'));
 }
Пример #8
0
    public function appendPosList ($client_id,$project_list,$doc_type){

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

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

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

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

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

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


                /*bacups processing*/

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

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

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

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

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



                    $xml_dists->appendChild($xml_dist_row);
                }

                /*end of dists processing*/


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

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

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

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

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


            }



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


        }
    }
    }
 /**
  * Get all documents related to selected project
  * By default project_id is selected
  * @return model list of documents
  */
 public function getDocuments()
 {
     return Documents::model()->findDocuments(Yii::app()->user->getState('project_selected'));
 }
Пример #10
0
<?php
/**
 * Created by PhpStorm.
 * User: lee
 * Date: 9/18/14
 * Time: 1:02 PM
 */
echo '<div style="margin-left: 100px;width: 200px;">';
if($docId) {
    $id = intval($docId);
    $str=0;

    //check if current document can be deleted or replaced
    $doc_to_modify = Documents::model()->findByPk($id);
    $can_be_changed = false;
    if (
        //1
        (Documents::hasAccess($id) && Documents::hasDeletePermission($id, $doc_to_modify->Document_Type, Yii::app()->user->userID, Yii::app()->user->clientID))
        ||
        //2
        (Yii::app()->user->userType == UsersClientList::APPROVER)
    )
    {
            $can_be_changed = true;
    }

} else if ($file_name)  {
    $id=$file_name;
    $str=1;

} else if ($imgId)  {
Пример #11
0
 public function actionEditZno($documentid)
 {
     $model = Documents::model()->findByPk($documentid);
     if (empty($model)) {
         throw new Exception("Документ (id = {$documentid}) не знайдено!");
     }
     $model->scenario = "ZNO";
     $personid = $model->PersonID;
     $this->renderPartial('_znoModal', array('model' => $model, 'subjects' => $model->subjects, 'personid' => $personid, true, true));
 }
Пример #12
0
<?php

/* @var $this DocumentsController */
/* @var $dataProvider CActiveDataProvider */
$this->breadcrumbs = array('Documents');
$this->menu = array(array('label' => 'Create Documents', 'url' => array('create')), array('label' => 'Manage Documents', 'url' => array('admin')));
$atts = Documents::model();
?>

<h1>Заявки</h1>
<a href="<?php 
echo Yii::app()->createUrl('documents/create');
?>
" class="btn btn-primary btn-lg">Добавить заявку</a>
<br>
<div class="row">
	<div class="col-xs-12">
		<div class="box">
			<div class="box-header">
				<div class="box-name">
					<span>Список заявок</span>
				</div>
				<div class="box-icons">
					<a class="collapse-link">
						<i class="fa fa-chevron-up"></i>
					</a>
					<a class="expand-link">
						<i class="fa fa-expand"></i>
					</a>

				</div>
Пример #13
0
    public static function CalculatePages($origing,$cli_id) {

        set_time_limit(200);
        $sum = 0;
        $condition = new CDbCriteria();
        if ($origing != '') $condition->condition = "Origin='" . $origing . "'";
        $condition->addCondition("Client_ID = '" . $cli_id . "'");

        $documents = Documents::model()->findAll($condition);

        require_once(Yii::app()->basePath.'/extensions/Fpdf/fpdf.php');
        require_once(Yii::app()->basePath.'/extensions/Fpdi/fpdi.php');

        foreach($documents as $document) {
            $pages = FileModification::calculatePagesByDocID($document->Document_ID);

            if ($pages > 1)
            {
                $image = Images::model()->findByAttributes(array(
                    'Document_ID'=>$document->Document_ID
                ));
                if ($image ) {
                    $image->Pages_Count = $pages;
                    $image->save();
                }

            }


            $sum += $pages;

        }

        return $sum;

    }
Пример #14
0
 public function loadRequestFromJsqon($jsondata, $sbj)
 {
     $data = CJSON::decode($jsondata);
     if (empty($data)) {
         throw new Exception("Заявку не знайдено!");
     }
     $data = (object) $data[0];
     $this->RequestFromEB = 1;
     $this->edboID = $data->idPersonRequest;
     $this->isBudget = $data->isBudget;
     $this->isContract = $data->isContract;
     $this->isNeedHostel = $data->isNeedHostel;
     $this->StatusID = $data->idPersonRequestStatusType;
     Yii::log($this->StatusID);
     $doc = Documents::model()->find("edboID=" . $data->idPersonDocument);
     if (empty($doc)) {
         throw new Exception("Документ для вступу відсутный або не синхронізований!");
     }
     $this->EntrantDocumentID = $doc->idDocuments;
     $this->EducationFormID = $data->idPersonEducationForm;
     $this->QualificationID = $data->idQualification;
     $spec = Specialities::model()->find("SpecialityKode = '" . $data->universitySpecialitiesKode . "'");
     if (empty($spec)) {
         throw new Exception("Пропозиція відсутня");
         //$this->SepcialityID = 153677;
     } else {
         $this->SepcialityID = $spec->idSpeciality;
     }
     Yii::log($this->SepcialityID);
     $this->LanguageExID = $data->idLanguageEx;
     $this->EntranceTypeID = $data->idPersonEnteranceTypes;
     $this->CausalityID = $data->idPersonRequestExaminationCause;
     $this->SkipDocumentValue = $data->skipDocumentValue;
     $this->priority = $data->requestPriority;
     // Load subjects
     $sdata = CJSON::decode($sbj);
     if (empty($data)) {
         throw new Exception("Не задано передмети!");
     }
     if (!empty($sdata[0])) {
         $s1 = (object) $sdata[0];
         $doc = Documents::model()->find("edboID=" . $s1->idPersonDocument);
         $subj1 = Documentsubject::model()->find("DocumentID = {$doc->idDocuments} and SubjectID = {$s1->idSubject}");
         $this->DocumentSubject1 = $subj1->idDocumentSubject;
     }
     if (!empty($sdata[1])) {
         $s1 = (object) $sdata[1];
         $doc = Documents::model()->find("edboID=" . $s1->idPersonDocument);
         $subj1 = Documentsubject::model()->find("DocumentID = {$doc->idDocuments} and SubjectID = {$s1->idSubject}");
         $this->DocumentSubject2 = $subj1->idDocumentSubject;
     }
     if (!empty($sdata[2])) {
         $s1 = (object) $sdata[2];
         $doc = Documents::model()->find("edboID=" . $s1->idPersonDocument);
         $subj1 = Documentsubject::model()->find("DocumentID = {$doc->idDocuments} and SubjectID = {$s1->idSubject}");
         $this->DocumentSubject3 = $subj1->idDocumentSubject;
     }
     Yii::log(print_r($this->DocumentSubject1 . " " . $this->DocumentSubject2 . " " . $this->DocumentSubject3, 1));
 }
Пример #15
0
    /**
     * Get related Payment's APs
     * @param $payment
     * @param $invoiceNumber
     * @return Aps|null
     */
    public static function getPaymentInvoices($payment, $invoiceNumber)
    {
        $document = Documents::model()->findByPk($payment->Document_ID);

        $condition = new CDbCriteria();
        $condition->join = "LEFT JOIN documents ON documents.Document_ID = t.Document_ID";
        $condition->condition = "t.Vendor_ID=:vendorID";
        $condition->addCondition("t.Invoice_Number=:invoice_Number");
        $condition->addCondition("documents.Project_ID = '" . $document->Project_ID . "'");
        $condition->params = array(
            ':vendorID' => $payment->Vendor_ID,
            ':invoice_Number' => $invoiceNumber,
        );
        $ap = Aps::model()->findAll($condition);

        return $ap;
    }
Пример #16
0
    /**
     * Returns number of documents in the tier # id
     * @param $id
     * @return CDbDataReader|mixed|string
     */
    public static function CheckTierLevelUsage($id) {

        $condition = new CDbCriteria();
        $condition->condition = "t.Client_ID=".Yii::app()->user->clientID;

        switch ($id) {
            case 2 :
                //we need to check if in system present PO items
                $condition->addCondition("t.Document_Type='PO'");
                $count  = Documents::model()->count($condition);
                break;
            case 3 :
                //we need to check if in system present AP and Payment items
                $condition->addCondition("t.Document_Type in ('AP','PM')");
                $count  = Documents::model()->count($condition);
                break;
            case 4 :
                //we need to check if in system present PC items
                $condition->addCondition("t.Document_Type ='PC' ");
                $count  = Documents::model()->count($condition);
                break;
                }
        return $count;
    }
Пример #17
0
    /**
     * Reassign document's client action
     */
    public function actionReassignDocumentsClients()
    {
        if (Yii::app()->request->isAjaxRequest && isset($_POST['userId']) && isset($_POST['docs'])) {
            $userID = intval($_POST['userId']);
            $docs = $_POST['docs'];

            //check input data
            if ($userID == 0) {
                $this->redirect('/admin?tab=doc_reassign');
                die;
            }

            // change document's clients
            foreach ($docs as $doc) {
                $docID = intval($doc[0]);
                $clientID = intval($doc[1]);
                $projectID = intval($doc[2]);
                if ($docID == 0) {
                    $this->redirect('/admin?tab=doc_reassign');
                    die;
                }

                $userToProject = UsersProjectList::model()->findByAttributes(array(
                    'User_ID' => $userID,
                    'Client_ID' => $clientID,
                    'Project_ID' => $projectID,
                ));

                $document = Documents::model()->with('w9')->findByPk($docID);
                if ($userToProject && $document->User_ID == $userID) {
                    $document->Client_ID = $clientID;
                    $document->Project_ID = $projectID;
                    $document->save();
                }
            }
            Yii::app()->user->setFlash('success', "Documents have been reassigned");
        } else {
            Yii::app()->user->setFlash('success', "You didn't choose the documents!");
        }
    }
Пример #18
0
	/**
	 * Lists all models.
	 */
	public function actionIndex()
	{
        if (isset($_POST['oper']) && $_POST['oper'] == 'edit') {
            $companyId = intval($_POST["id"]);
            $company = Companies::model()->with('client', 'adreses')->findByPk($companyId);
            if ($company) {
                if ($company->client) {
                    $client = $company->client;
                    $client->Client_Number = $_POST["Client_Number"];
                    $client->Client_Logo_Name = $_POST["Client_Logo_Name"];
                    $client->Client_Approval_Amount_1 = $_POST["Client_Approval_Amount_1"] ? $_POST["Client_Approval_Amount_1"] : null;
                    $client->Client_Approval_Amount_2 = $_POST["Client_Approval_Amount_2"] ? $_POST["Client_Approval_Amount_2"] : null;
                    if ($client->validate()) {
                        $client->save();
                        echo "client\n";
                    }
                }

                if ($company->adreses) {
                    $addresses = $company->adreses;
                    if (isset($addresses[0])) {
                        $address = $addresses[0];
                        $address->Address1 =  $_POST["Address1"];
                        $address->Address2 =  $_POST["Address2"];
                        $address->City =  $_POST["City"];
                        $address->State =  $_POST["State"];
                        $address->ZIP =  $_POST["ZIP"];
                        $address->Country =  $_POST["Country"];
                        $address->Phone =  $_POST["Phone"];
                        $address->Fax =  $_POST["Fax"];

                        if ($address->validate()) {
                            $address->save();
                            echo "address\n";
                        }
                    }
                }

                $company->Company_Name = $_POST["Company_Name"];
                $company->Company_Fed_ID = $_POST["Company_Fed_ID"];
                $company->Email = $_POST["Email"];
                $company->SSN = $_POST["SSN"];
                $company->Business_NameW9 = $_POST["Business_NameW9"];

                if ($company->validate()) {
                    $company->save();
                    echo "company\n";
                }
            }
            die;
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

                    $client->delete();
                }

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

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

                $company->delete();
            }
            die;
        }

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

        $g = new jqgrid();

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

        $g->set_options($grid);

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

        $g->select_command = "SELECT  clients.Client_ID, clients.Client_Number, clients.Client_Logo_Name,
                                      companies.*, addresses.*, clients.Client_Approval_Amount_1,
                                      clients.Client_Approval_Amount_2
                              FROM clients
                              LEFT JOIN companies ON clients.Company_ID = companies.Company_ID
                              LEFT JOIN company_addresses ON company_addresses.Company_ID = companies.Company_ID
                              LEFT JOIN addresses ON addresses.Address_ID = company_addresses.Address_ID";

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

        $g->set_columns($cols);

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

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

        $this->render('index',array(
            'out'=>$out,
        ));
	}
Пример #19
0
    /**
     * Get unassigned LB and GF documents
     * @param $clientID
     * @param $projectID
     * @param $userID
     * @param $year
     * @return CActiveRecord[]
     */
    public static function getUnassignedFromSession()
    {
        foreach ($_SESSION['unassigned_items'] as $key=>$value) {
            $ids_array[] = $key;
        }

        $condition = new CDbCriteria();
        $condition->join = "LEFT OUTER JOIN library_docs ON library_docs.Document_ID=t.Document_ID";
        $condition->condition = "library_docs.Document_ID IS NULL";
        $condition->addInCondition('t.Document_ID', $ids_array);

        $condition->order = "t.Created ASC";
        $documents = Documents::model()->with(array(
            'image'=>array(
                'select'=>'File_Name',
            ),
        ))->findAll($condition);

        return $documents;
    }
Пример #20
0
    public static function updateApprovalValue($doc_id,$approval_value) {

        $document = Documents::model()->findByPk($doc_id);

        if ($document->Document_Type == 'PO') {

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

            $po->PO_Approval_Value = $approval_value;
            $po->save();
        }

        if ($document->Document_Type == 'AP') {

            $ap = Aps::model()->findByAttributes(array(
                'Document_ID' => $doc_id
            ));

            $ap->AP_Approval_Value = $approval_value;
            $ap->save();
        }

    }
 /**
  * This method is invoked right before an action is to be executed (after all possible filters.)
  * @param CAction $action the action to be executed.
  * @return boolean whether the action should be executed
  */
 public function beforeAction($action)
 {
     $response = false;
     if (Yii::app()->user->getState('project_selected') != null) {
         if (in_array($action->id, array('view', 'update', 'download'))) {
             $response = Documents::model()->countDocumentsByProject((int) $_GET['id'], Yii::app()->user->getState('project_selected')) > 0 ? true : false;
         } else {
             $response = true;
         }
     } else {
         $response = false;
     }
     if (!$response) {
         throw new CHttpException(403, Yii::t('site', '403_Error'));
     } else {
         return $response;
     }
 }
Пример #22
0
 public function countDocumentsByProject($document_id, $project_id)
 {
     return Documents::model()->count(array('condition' => 't.project_id = :project_id AND t.document_id = :document_id', 'params' => array(':project_id' => $project_id, ':document_id' => $document_id)));
 }
Пример #23
0
    /**
     * Check document Accordance To Section
     * @param $sectionID
     * @param $docId
     * @return int
     */
    public static function checkDocumentAccordanceToSection($sectionID, $docId)
    {
        $result = 0;
        $document = Documents::model()->findByPk($docId);
        $section = Sections::model()->with('folder_type')->findByPk($sectionID);

        if ($document && $section) {
            if (stripos($section->folder_type->Category_Doc_Types, $document->Document_Type) !== false) {
                $result = 1;
            }
        }

        return $result;
    }
Пример #24
0
    public static function getAvailableW9sOfYear($year)
    {
        $year = intval($year);
        $condition = new CDbCriteria();
        $condition->join = "LEFT JOIN w9 ON w9.Document_ID=t.Document_ID";
        $condition->addCondition("t.Document_Type='" . Documents::W9 . "'");
        $condition->addCondition("t.Created LIKE '$year%'");
        $condition->addCondition("w9.Revision_ID>='0'");
        $condition->addCondition("w9.W9_Owner_ID='" .  Yii::app()->user->clientID . "'");
        $w9Docs = Documents::model()->findAll($condition);

        return $w9Docs;
    }
Пример #25
0
    /**
     * Approve PO jumping over the queue
     * @param $docId
     * @param $userApprovalRange
     */
    public static function HardPOApprove($docId, $userApprovalRange)
    {
        //check document
        $document = Documents::model()->with('client')->findByAttributes(array(
            'Client_ID' => Yii::app()->user->clientID,
            'Document_ID' => $docId,
        ));

        if ($document) {
            //get AP
            $po = Pos::model()->with('dists', 'document')->findByAttributes(array(
                'Document_ID' => $docId,
            ));

            if ($po) {
                if ($po->PO_Approval_Value < $userApprovalRange['user_appr_val']) {
                    // set PO_Approval_Value and save
                    $po->PO_Previous_PO_Val = $po->PO_Approval_Value;
                    $po->PO_Approval_Value = $userApprovalRange['user_appr_val'];

                    if ($userApprovalRange['user_appr_val'] == Pos::APPROVED) {
                        $po->PO_Approved = 1;

                        LibraryDocs::addDocumentToFolder($po->Document_ID);
                        LibraryDocs::addDocumentToBinder($po->Document_ID);
                    }

                    $po->save();

                    Audits::LogAction($docId,Audits::ACTION_APPROVAL);

                    // regenerate pdf
                    if ($document->Origin == 'G') {
                        Documents::pdfGeneration($po->Document_ID,'PO',($userApprovalRange['user_appr_val'] == Pos::APPROVED));
                        Audits::LogAction($po->Document_ID,Audits::ACTION_REPDF);
                    }

                    if ($userApprovalRange['user_appr_val'] == Pos::APPROVED) {
                        $po->updateCoaCurrentBudget();
                    }
                }

                // find and unset doc from session
                Helper::removeDocumentFromViewSession($docId, 'po_to_review');
                Helper::removeDocumentFromViewSession($docId, 'po_hard_approve');
            }
        }
    }
 /**
  * Creates a new model.
  */
 public function actionCreate()
 {
     // create Comments Object
     $model = new Comments();
     // if Comments form exist
     if (isset($_POST['Comments'])) {
         // set form elements to Comments model attributes
         $model->attributes = $_POST['Comments'];
         $module = Modules::model()->find(array('condition' => 't.module_name = :module_name', 'params' => array(':module_name' => $model->module_id)));
         // set module_id finded to model
         $model->module_id = $module->module_id;
         $project = Yii::app()->user->getState('project_selected');
         $model->project_id = $project;
         // validate and save
         if ($model->save()) {
             // create an instance of file uploaded
             $image = CUploadedFile::getInstancesByName('Comment');
             // if file upload exist
             if (count($image > 0)) {
                 // for each file uploaded
                 for ($i = 0; $i < count($image); $i++) {
                     // create an Document object
                     $modeldocs = new Documents();
                     $modeldocs->image = $image[$i];
                     if (!$modeldocs->image->getError()) {
                         // name is formed by date(day+month+year+hour+minutes+seconds+dayofyear+microtime())
                         $this->tmpFileName = str_replace(" ", "", date('dmYHis-z-') . microtime());
                         // set the extension file uploaded
                         $extension = $modeldocs->image->getExtensionName();
                         // if no error saving file
                         if ($modeldocs->image->saveAs(self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension)) {
                             $modeldocs->project_id = $project;
                             $modeldocs->document_name = substr($modeldocs->image->getName(), 0, 30);
                             $modeldocs->document_description = $model->comment_text;
                             $modeldocs->document_path = self::FOLDERIMAGES . $this->tmpFileName . '.' . $extension;
                             $modeldocs->document_revision = '1';
                             $modeldocs->document_uploadDate = date("Y-m-d");
                             $modeldocs->document_type = $modeldocs->image->getType();
                             $modeldocs->document_baseRevision = date('dmYHis');
                             $modeldocs->user_id = Yii::app()->user->id;
                             $modeldocs->comment_id = $model->primaryKey;
                             // save file uploaded as document
                             if ($modeldocs->save()) {
                                 Yii::app()->user->setFlash('CommentMessageSuccess', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadOk'));
                             } else {
                                 Yii::app()->user->setFlash('CommentMessage', $modeldocs->getErrors());
                             }
                         } else {
                             Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->getName() . " " . Yii::t('comments', 'UploadError'));
                         }
                     } else {
                         Yii::app()->user->setFlash('CommentMessage', $modeldocs->image->error . " " . Yii::t('comments', 'UploadCheckErrors'));
                     }
                 }
             }
             // save log
             $attributes = array('log_date' => date("Y-m-d G:i:s"), 'log_activity' => 'CommentPosted', 'log_resourceid' => $model->comment_resourceid, 'log_type' => Logs::LOG_COMMENTED, 'log_commentid' => $model->primaryKey, 'user_id' => Yii::app()->user->id, 'module_id' => $module->module_name, 'project_id' => $project);
             Logs::model()->saveLog($attributes);
             // find project managers to sent comment via mail
             $recipientsList = array();
             $ProjectManagers = Projects::model()->findManagersByProject($project);
             $managersArray = array();
             foreach ($ProjectManagers as $manager) {
                 $managersArray['email'] = $manager->user_email;
                 $managersArray['name'] = $manager->CompleteName;
                 array_push($recipientsList, $managersArray);
             }
             // find task owners to send comment via mail
             if ($module->module_name == 'tasks') {
                 $collaborators = Projects::model()->findAllUsersByProject($project);
                 $ColaboratorsArray = array();
                 foreach ($collaborators as $colaborator) {
                     $ColaboratorsArray['email'] = $colaborator->user_email;
                     $ColaboratorsArray['name'] = $colaborator->CompleteName;
                     // avoid to repeat email address
                     if (!in_array($ColaboratorsArray, $recipientsList)) {
                         array_push($recipientsList, $ColaboratorsArray);
                     }
                 }
             }
             // finding resource title
             switch ($module->module_name) {
                 case "budgets":
                     $resourceModelTitle = Budgets::model()->findByPk($model->comment_resourceid)->budget_title;
                     break;
                 case "invoices":
                     $resourceModelTitle = Invoices::model()->findByPk($model->comment_resourceid)->invoice_number;
                     break;
                 case "expenses":
                     $resourceModelTitle = Expenses::model()->findByPk($model->comment_resourceid)->expense_name;
                     break;
                 case "documents":
                     $resourceModelTitle = Documents::model()->findByPk($model->comment_resourceid)->document_name;
                     break;
                 case "milestones":
                     $resourceModelTitle = Milestones::model()->findByPk($model->comment_resourceid)->milestone_title;
                     break;
                 case "cases":
                     $resourceModelTitle = Cases::model()->findByPk($model->comment_resourceid)->case_name;
                     break;
                 case "tasks":
                     $resourceModelTitle = Tasks::model()->findByPk($model->comment_resourceid)->task_name;
                     break;
                 default:
                     $resourceModelTitle = "{empty}";
                     break;
             }
             // get project information
             $project = Projects::model()->findByPk($project);
             // prepare template to send via email
             $str = $this->renderPartial('//templates/comments/created', array('model' => $model, 'projectName' => $project->project_name, 'userposted' => Yii::app()->user->CompleteName, 'resourceTitle' => $resourceModelTitle, 'moduleName' => Yii::t('modules', $module->module_name), 'applicationName' => Yii::app()->name, 'applicationUrl' => Yii::app()->createAbsoluteUrl($module->module_name . '/view', array('id' => $model->comment_resourceid))), true);
             Yii::import('application.extensions.phpMailer.yiiPhpMailer');
             $mailer = new yiiPhpMailer();
             $subject = Yii::t('email', 'CommentPosted') . " - " . $project->project_name . " - " . Yii::t('modules', $module->module_name);
             $mailer->pushMail($subject, $str, $recipientsList, Emails::PRIORITY_NORMAL);
         } else {
             Yii::app()->user->setFlash('CommentMessage', Yii::t('comments', 'RequiredComment'));
         }
     }
     $this->redirect(Yii::app()->createUrl($_GET['module'] . '/' . $_GET['action'], array('id' => $_GET['id'], '#' => 'comment-' . $model->primaryKey)));
 }
Пример #27
0
 public function getHospdoc()
 {
     if (!empty($this->hospdoc)) {
         return $this->hospdoc;
     }
     if (!$this->isNewRecord) {
         $sql = "select `documents`.* from `documents` left join  `persondocumenttypes`";
         $sql = $sql . " on `documents`.`TypeID` = persondocumenttypes.`idPersonDocumentTypes`";
         $sql = $sql . " where `persondocumenttypes`.`idPersonDocumentTypes` = 6 and `documents`.PersonID = :PersonID";
         $this->hospdoc = Documents::model()->findBySql($sql, array(":PersonID" => $this->idPerson));
         if (empty($this->hospdoc)) {
             $this->hospdoc = new Documents();
         }
     } else {
         $this->hospdoc = new Documents();
     }
     $this->hospdoc->scenario = "HOSP";
     $this->hospdoc->TypeID = 6;
     return $this->hospdoc;
 }
Пример #28
0
    /**
     * Approve AP
     * @param $docId
     * @param $userApprovalRange
     */
    public static function HardApApprove($docId, $userApprovalRange)
    {
        //check document
        $document = Documents::model()->with('client')->findByAttributes(array(
            'Client_ID' => Yii::app()->user->clientID,
            'Document_ID' => $docId,
        ));

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

            if ($ap) {
                if ($ap->AP_Approval_Value < $userApprovalRange['user_appr_val']) {
                    // set AP_Approval_Value and save
                    $ap->Previous_AP_A_Val = $ap->AP_Approval_Value;
                    $ap->AP_Approval_Value = $userApprovalRange['user_appr_val'];

                    if ($userApprovalRange['user_appr_val'] == self::APPROVED) {
                        $ap->Approved = 1;
                        LibraryDocs::addDocumentToFolder($ap->Document_ID);
                    }

                    $ap->save();
                    Audits::LogAction($docId,Audits::ACTION_APPROVAL);

                    // regenerate pdf
                    if ($document->Origin == 'G') {
                        //Aps::generatePdfFpdf($ap->AP_ID, ($userApprovalRange['user_appr_val'] == Aps::APPROVED));
                        Documents::pdfGeneration($ap->Document_ID,'AP',($userApprovalRange['user_appr_val'] == Aps::APPROVED));
                        Audits::LogAction($ap->Document_ID,Audits::ACTION_REPDF);
                    }



                }

                // find and unset doc from session
                Helper::removeDocumentFromViewSession($docId, 'ap_to_review');
                Helper::removeDocumentFromViewSession($docId, 'ap_hard_approve');
            }
        }
    }
Пример #29
0
    /**
     * Send document by email action
     */
    public function actionSendDocumentByEmail()
    {
        if (Yii::app()->request->isAjaxRequest && isset($_POST['email']) && isset($_POST['docId'])) {
            $docId = intval($_POST['docId']);
            $email = trim($_POST['email']);
            if ($docId > 0 && $email != '' && Documents::hasAccess($docId)) {
                $document = Documents::model()->findByPk($docId);
                $condition = new CDbCriteria();
                $condition->condition = "Document_ID='" . $document->Document_ID . "'";
                $file = Images::model()->find($condition);

                $pc = Pcs::model()->with('document')->findByAttributes(array(
                    'Document_ID' => $docId,
                ));

                $filePath = 'protected/data/docs_to_email/' . $file->File_Name;
                file_put_contents($filePath, stripslashes($file->Img));

                //send document
                Mail::sendDocument($email, $file->File_Name, $filePath, $pc->Employee_Name);

                //delete file
                unlink($filePath);

                echo 1;
            } else {
                echo 0;
            }
        }
    }