예제 #1
0
 public function welcomeAction()
 {
     $auth = Zend_Auth::getInstance();
     $businessunit_id = '';
     $department_id = '';
     if ($auth->hasIdentity()) {
         $businessunit_id = $auth->getStorage()->read()->businessunit_id;
         $department_id = $auth->getStorage()->read()->department_id;
         $loginUserId = $auth->getStorage()->read()->id;
         $loginuserRole = $auth->getStorage()->read()->emprole;
     }
     $widgetsModel = new Default_Model_Widgets();
     // Birthdays & Announcements
     $birthdaysRes = $widgetsModel->getTodaysBirthdays($businessunit_id, $department_id);
     $upcomingBirthdyas = $widgetsModel->getUpcomingBirthdays($businessunit_id, $department_id);
     $this->view->todyasBirthdays = $birthdaysRes;
     $this->view->upcomingBirthdyas = $upcomingBirthdyas;
     // Announcements - START
     $announcementsModel = new Default_Model_Announcements();
     $announcementsData = $announcementsModel->getAllByBusiAndDeptId();
     $this->view->announcementsData = $announcementsData;
     // Announcements - END
     //Widgets formats
     //Interview Schedules = 'format1';
     //My Service Request = 'format2';
     //Request Pending Approval = 'format3';
     //Leaves Available = 'format4';
     //My Leaves This Month = 'format5';
     //Leave Management Options = 'format6';
     //My details = 'format7';
     $menuIdsArr = array(57 => 'format1', 10 => 'format5', 11 => 'format5', 20 => 'format5', 21 => 'format5', 14 => 'format4', 23 => 'format2', 32 => 'format7', 34 => 'format4', 35 => 'format5', 41 => 'format5', 42 => 'format5', 45 => 'format3', 54 => 'format4', 55 => 'format5', 56 => 'format4', 61 => 'format3', 65 => 'format3', 44 => 'format6', 43 => 'format5', 80 => 'format5', 86 => 'format5', 87 => 'format5', 88 => 'format5', 89 => 'format5', 90 => 'format5', 91 => 'format5', 92 => 'format5', 93 => 'format5', 100 => 'format5', 101 => 'format5', 102 => 'format5', 103 => 'format5', 107 => 'format5', 108 => 'format5', 110 => 'format5', 111 => 'format5', 114 => 'format5', 115 => 'format5', 116 => 'format5', 117 => 'format5', 118 => 'format5', 120 => 'format5', 121 => 'format5', 123 => 'format5', 124 => 'format5', 125 => 'format5', 126 => 'format5', 127 => 'format5', 128 => 'format5', 132 => 'format5', 136 => 'format5', 140 => 'format5', 143 => 'format3', 144 => 'format5', 145 => 'format5', 146 => 'format5', 148 => 'format3', 150 => 'format5', 151 => 'format5', 152 => 'format5', 154 => 'format4', 155 => 'format5', 165 => 'format5', 166 => 'format5', 62 => 'format3', 63 => 'format3', 64 => 'format3', 68 => 'format3', 69 => 'format3', 85 => 'format3', 131 => 'format5', 134 => 'format3', 135 => 'format3', 138 => 'format3', 139 => 'format3', 140 => 'format5', 142 => 'format5', 151 => 'format5', 154 => 'format6', 158 => 'format5', 159 => 'format5', 160 => '', 161 => 'format3', 165 => 'format5', 166 => 'format5', 167 => 'format6', 168 => '', 174 => 'format5', 169 => 'format3', 170 => 'format3', 172 => 'format5', 174 => 'format5');
     $getMenuIds = $widgetsModel->getWidgets($loginUserId, $loginuserRole);
     $htmlcontent = '';
     $tmpHtml1 = "";
     $tmpHtml5 = "";
     $tmpHtml2 = "";
     $tmpHtml3 = "";
     $tmpHtml4 = "";
     $format = '';
     if (!empty($getMenuIds)) {
         //$i,j for css color changing for widgets
         $i = 1;
         $j = 1;
         foreach ($getMenuIds as $getMenuIdArr) {
             $i = $i >= 5 ? $i - 4 : $i;
             // I for format 2,3,4
             $j = $i >= 5 ? $j - 4 : $j;
             // J for format 5
             $menuId = $getMenuIdArr['id'];
             $url = $getMenuIdArr['url'];
             $format = isset($menuIdsArr[$menuId]) ? $menuIdsArr[$menuId] : '';
             if ($menuId == 57) {
                 $tmpHtml1 = sapp_Global::format1($url);
             } else {
                 if ($format == 'format2') {
                     $tmpHtml2 .= sapp_Global::format2($menuId, $i, $url);
                     $i++;
                 } else {
                     if ($format == 'format3') {
                         $tmpHtml2 .= sapp_Global::format3($menuId, $i, $url);
                         $i++;
                     } else {
                         if ($format == 'format4') {
                             $tmpHtml2 .= sapp_Global::format4($menuId, $i, $url);
                             $i++;
                         } else {
                             if ($format == 'format5') {
                                 $tmpHtml5 .= sapp_Global::format5($menuId, $j, $url);
                                 $j++;
                             } else {
                                 if ($format == 'format6') {
                                     $tmpHtml5 .= sapp_Global::format6($menuId, $url);
                                     $j++;
                                 } else {
                                     if ($format != '') {
                                         $htmlcontent .= sapp_Global::format7($menuId, $url);
                                     } else {
                                         if ($format == '') {
                                             $htmlcontent = '';
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
         //$htmlcontent = '<div class="left_dashboard">'.$tmpHtml1.$tmpHtml2.$tmpHtml4.$tmpHtml3.$tmpHtml5.$htmlcontent.'</div>';
         $htmlcontent = '<div class="left_dashboard">' . $tmpHtml1 . $tmpHtml2 . '<div class="clear"></div>' . $tmpHtml5 . $htmlcontent . '</div>';
     }
     $this->view->htmlcontent = $htmlcontent;
 }
 public function uploaddeleteAction()
 {
     if (isset($_POST["op"]) && $_POST["op"] == "delete" && isset($_POST['doc_new_name'])) {
         $filePath = CA_UPLOAD_PATH . $_POST['doc_new_name'];
         if (isset($_POST["a_id"]) && $_POST["a_id"] != '' && isset($_POST["status"])) {
             // Update attachments field in database by removing deleted attachment
             $announcementsModel = new Default_Model_Announcements();
             $annData = $announcementsModel->getAnnouncementsDatabyID($_POST["a_id"]);
             if ($annData[0]['attachments']) {
                 $attData = json_decode($annData[0]['attachments'], true);
                 foreach ($attData as $key => $attachment) {
                     if ($attachment['new_name'] == $_POST['doc_new_name']) {
                         unset($attData[$key]);
                         break;
                     }
                 }
                 $data = array('attachments' => count($attData) > 0 ? json_encode($attData) : null);
                 $where = array('id=?' => $_POST["a_id"]);
                 $announcementsModel->SaveorUpdateAnnouncementsData($data, $where);
             }
             // Get file path of attachment to be removed.
             if ($_POST["status"] == 1) {
                 // Path of attachment files when Announcement saved as draft
                 $filePath = CA_TEMP_UPLOAD_PATH . $_POST['doc_new_name'];
             }
             // Remove attachment files from upload folder.
             if (file_exists($filePath)) {
                 unlink($filePath);
             }
             // Update photo gallery with removed attachment
             if ($_POST["status"] == 2) {
                 $path = CA_FILES_PATH;
             } else {
                 $path = CA_FILES_TEMP_PATH;
             }
             $this->view->path = $path;
             $this->view->attachments = $attData;
         } else {
             // Remove attachment files from upload folder.
             if (file_exists($filePath)) {
                 unlink($filePath);
             }
             $this->_helper->json(array());
         }
     }
 }