예제 #1
0
 public function actionNotAccept($id)
 {
     $model = $this->loadModel($id);
     $model->status = 5;
     if ($model->save()) {
         $paperAccept = Accept::model()->find(array('condition' => 'paper_id = :paper_id and type_paper_id = 2', 'params' => array(':paper_id' => $model->paper_approval_bus_id), 'order' => 'accept_id desc'));
         $paperAccept->personnel_id = Yii::app()->user->id;
         $paperAccept->use = 0;
         if ($paperAccept->save()) {
             $paperAccept = new Accept();
             $paperAccept->paper_id = $model->paper_approval_bus_id;
             $paperAccept->personnel_id = Yii::app()->user->id;
             $paperAccept->status = 4;
             $paperAccept->type_paper_id = 2;
             $paperAccept->use = 1;
             $paperAccept->create_at = date('Y-m-d H:i:s');
             $paperAccept->save();
             $this->redirect(array('/doing1'));
         }
     }
 }
 public function actionCreate()
 {
     $model = new PaperApproval();
     $file = new FileOther();
     $model->member_id = Yii::app()->user->id;
     $model->paper_no = $this->getPaperNo();
     $model->status = 1;
     $model->create_at = date('Y-m-d H:i:s');
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['PaperApproval']) && isset($_POST['FileOther'])) {
         $model->attributes = $_POST['PaperApproval'];
         $file->attributes = $_POST['FileOther'];
         $file->file = CUploadedFile::getInstance($file, 'file');
         if ($file->file != null) {
             $filename = time() . '.' . $file->file->getExtensionName();
             $file->file->saveAs(Yii::app()->params['pathUpload'] . $filename);
             $model->file = $filename;
         }
         $model->validate();
         if ($model->getErrors() == null) {
             $model->departure_time = Tools::dateToSave($model->departure_time);
             $model->back_time = Tools::dateToSave($model->back_time);
             if ($model->save()) {
                 $paperAccept = new Accept();
                 $paperAccept->paper_id = $model->paper_approval_id;
                 $paperAccept->personnel_id = 0;
                 $paperAccept->status = 1;
                 $paperAccept->use = 1;
                 $paperAccept->type_paper_id = 1;
                 $paperAccept->create_at = date('Y-m-d H:i:s');
                 $paperAccept->save();
                 $this->redirect(array('view', 'id' => $model->paper_approval_id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'file' => $file));
 }
예제 #3
0
 public function actionView()
 {
     if (!isset($_GET['paper_approval_id'])) {
         $model = $this->loadModel($_POST['paper_approval_id']);
     } else {
         $model = $this->loadModel($_GET['paper_approval_id']);
     }
     $condition = new ConditionAccept();
     $noAccept = new PaperDetail();
     $accept = new PaperDetailAccept();
     $accept->paper_id = $model->paper_approval_id;
     $accept->member_id = Yii::app()->user->id;
     $accept->create_at = date('Y-m-d H:i:s');
     $noAccept->paper_id = $model->paper_approval_id;
     $noAccept->member_id = Yii::app()->user->id;
     $noAccept->create_at = date('Y-m-d H:i:s');
     $condition->condition = 0;
     if (isset($_POST['ConditionAccept'])) {
         $condition->attributes = $_POST['ConditionAccept'];
         if ($condition->condition == 0) {
             // อนุมัติ
             if (isset($_POST['PaperDetailAccept'])) {
                 $accept->attributes = $_POST['PaperDetailAccept'];
                 if ($accept->validate()) {
                     $model->status = 2;
                     if ($model->save()) {
                         if ($accept->save()) {
                             $paperAccept = Accept::model()->find(array('condition' => 'paper_id = :paper_id and type_paper_id = 1', 'params' => array(':paper_id' => $model->paper_approval_id), 'order' => 'accept_id desc'));
                             $paperAccept->personnel_id = Yii::app()->user->id;
                             $paperAccept->use = 0;
                             if ($paperAccept->save()) {
                                 $paperAccept = new Accept();
                                 $paperAccept->paper_id = $model->paper_approval_id;
                                 $paperAccept->personnel_id = Yii::app()->user->id;
                                 $paperAccept->status = 2;
                                 $paperAccept->type_paper_id = 1;
                                 $paperAccept->use = 1;
                                 $paperAccept->create_at = date('Y-m-d H:i:s');
                                 $paperAccept->save();
                                 echo CJSON::encode(array('status' => 'success', 'message' => 'อนุมัติ'));
                             }
                         } else {
                             echo "<pre>";
                             print_r($accept->attributes);
                         }
                     }
                 } else {
                     $error = CActiveForm::validate($accept);
                     if ($error != '[]') {
                         echo $error;
                     }
                     Yii::app()->end();
                 }
                 //                    echo '<pre>';
                 //                    print_r($accept->attributes);
                 Yii::app()->end();
             }
         } else {
             if ($condition->condition == 1) {
                 // ไม่อนุมัติ
                 if (isset($_POST['PaperDetail'])) {
                     $noAccept->attributes = $_POST['PaperDetail'];
                     if ($noAccept->validate()) {
                         $model->status = 5;
                         if ($model->save()) {
                             if ($noAccept->save()) {
                                 $paperAccept = Accept::model()->find(array('condition' => 'paper_id = :paper_id and type_paper_id = 1', 'params' => array(':paper_id' => $model->paper_approval_id), 'order' => 'accept_id desc'));
                                 $paperAccept->personnel_id = Yii::app()->user->id;
                                 $paperAccept->use = 0;
                                 if ($paperAccept->save()) {
                                     $paperAccept = new Accept();
                                     $paperAccept->paper_id = $model->paper_approval_id;
                                     $paperAccept->personnel_id = Yii::app()->user->id;
                                     $paperAccept->status = 4;
                                     $paperAccept->type_paper_id = 1;
                                     $paperAccept->use = 1;
                                     $paperAccept->create_at = date('Y-m-d H:i:s');
                                     $paperAccept->save();
                                     echo CJSON::encode(array('status' => 'success', 'message' => 'ไม่อนุมัติ'));
                                 }
                             }
                         }
                     } else {
                         $error = CActiveForm::validate($noAccept);
                         if ($error != '[]') {
                             echo $error;
                         }
                         Yii::app()->end();
                     }
                     //                    echo '<pre>';
                     //                    print_r($noAccept->attributes);
                     Yii::app()->end();
                 }
             }
         }
     }
     $this->renderPartial('view_list', array('model' => $model, 'condition' => $condition, 'noAccept' => $noAccept, 'accept' => $accept), false, true);
 }
예제 #4
0
<?php

$paperAccept = Accept::model()->BossCarAccept()->findAll();
?>
<li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
        <i class="fa fa-bell fa-lg"></i>
        <?php 
if (count($paperAccept) > 0) {
    ?>
            <span class="notification-label bounceIn animation-delay6"><?php 
    echo count($paperAccept);
    ?>
</span>
        <?php 
}
?>
    </a>
    <ul class="dropdown-menu notification dropdown-3">
        <li><a href="#">คำร้องที่ต้องตรวจรับทั้งหมด <?php 
echo count($paperAccept);
?>
 คำร้อง</a></li>					  
        <?php 
foreach ($paperAccept as $value) {
    ?>
            <li>
                <?php 
    if ($value->status == 1) {
        ?>
                    <a href="#" data-paper-id="<?php 
 public function actionCreate()
 {
     $model = new PaperApprovalBus();
     $file = new FileOther();
     $model->member_id = Yii::app()->user->id;
     $model->paper_no = $this->getPaperNo();
     $model->status = 0;
     $model->create_at = date('Y-m-d H:i:s');
     $service_radio = 0;
     if (isset($_POST['service-radio'])) {
         $service_radio = $_POST['service-radio'];
     }
     $service_room = 0;
     if (isset($_POST['service_room-radio'])) {
         $service_room = $_POST['service_room-radio'];
     }
     // Uncomment the following line if AJAX validation is needed
     $this->performAjaxValidation($model);
     if (isset($_POST['PaperApprovalBus']) && isset($_POST['FileOther'])) {
         $model->attributes = $_POST['PaperApprovalBus'];
         $file->attributes = $_POST['FileOther'];
         if ($model->service_charge_cleaning > 500) {
             $model->addError('service_charge_cleaning', 'ครั้งละไม่เกิน 500 บาท');
         }
         if ($service_radio == 0) {
             $model->service_charge_out = 0;
         }
         if ($service_radio == 1) {
             $model->service_charge_in = 0;
         }
         if ($service_room == 0) {
             $model->service_room_multi = 0;
         }
         if ($service_room == 1) {
             $model->service_room = 0;
         }
         $file->file = CUploadedFile::getInstance($file, 'file');
         if ($file->file != null) {
             $filename = time() . '.' . $file->file->getExtensionName();
             $file->file->saveAs(Yii::app()->params['pathUpload'] . $filename);
             $model->file = $filename;
         }
         $model->validate();
         $file->validate();
         if ($model->getErrors() == null && $file->getErrors() == null) {
             $model->date_start = Tools::dateToSave($model->date_start);
             $model->date_end = Tools::dateToSave($model->date_end);
             if ($model->save()) {
                 $paperAccept = new Accept();
                 $paperAccept->paper_id = $model->paper_approval_bus_id;
                 $paperAccept->personnel_id = 0;
                 $paperAccept->status = 1;
                 $paperAccept->use = 1;
                 $paperAccept->type_paper_id = 2;
                 $paperAccept->create_at = date('Y-m-d H:i:s');
                 $paperAccept->save();
                 $this->redirect(array('view', 'id' => $model->paper_approval_bus_id));
             }
         }
     }
     $this->render('create', array('model' => $model, 'file' => $file, 'service_radio' => $service_radio, 'service_room' => $service_room));
 }
<?php

if (Yii::app()->user->isRector()) {
    $paperAccept = Accept::model()->doing1()->desc()->findAll();
} else {
    if (Yii::app()->user->isViceRector()) {
        $paperAccept = Accept::model()->rector_vicerector()->desc()->findAll();
    }
}
?>
<li class="dropdown">
    <a class="dropdown-toggle" data-toggle="dropdown" href="#">
        <i class="fa fa-bell fa-lg"></i>
        <?php 
if (count($paperAccept) > 0) {
    ?>
            <span class="notification-label bounceIn animation-delay6"><?php 
    echo count($paperAccept);
    ?>
</span>
        <?php 
}
?>
    </a>
    <ul class="dropdown-menu notification dropdown-3">
        <li><a href="#">คำร้องทั้งหมด <?php 
echo count($paperAccept);
?>
 เรื่อง</a></li>					  
        <?php 
foreach ($paperAccept as $value) {