Пример #1
0
 * 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)  {
    $id= $imgId;
    $str=0;
Пример #2
0
    public function actionRotate(){

        $result['success'] = false;

        if(Yii::app()->request->isAjaxRequest && $_POST['docID']){

            // start profiling
            //xhprof_enable(XHPROF_FLAGS_MEMORY);

            $doc_id= intval($_POST['docID']);

            $rotate_direction=strval ($_POST['action']);

            if ($doc_id > 0 && Documents::hasAccess($doc_id)) {

                                     $return_array=FileModification::prepareFile($doc_id);

                if($return_array['ext']!='pdf'){
                    $return_array = FileModification::ImageToPdf($return_array['path_to_dir'],$return_array['filename'],$return_array['ext']);
                }

                if(!$result['error']) {
                    $result=FileModification::rotateFile($return_array['path_to_dir'],$return_array['filename'],$rotate_direction);
                    $result['success'] = true;
                } else {
                    $result['success'] = false;
                    $result['error_message'] = "File was not rendered.";
                }


                if(!$result['error']) {
                $return_array = FileModification::writeToBase($return_array['path_to_dir'],$return_array['filename'],'application/pdf',$doc_id);

                    $result['file_id'] = FileCache::updateFileInCache($doc_id);

                    $result['success'] = true;

                } else {
                    $result['success'] = false;
                    $result['error_message'] = "File was not rendered.";
                }


            }

            // stop profiler
           /* $xhprof_data = xhprof_disable();
            include_once "/usr/share/php/xhprof_lib/utils/xhprof_lib.php";
            include_once "/usr/share/php/xhprof_lib/utils/xhprof_runs.php";
            $xhprof_runs = new XHProfRuns_Default();
            $run_id = $xhprof_runs->save_run($xhprof_data, "filemodification");
            */

        }

        echo CJSON::encode($result);
    }
Пример #3
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;
            }
        }
    }