Example #1
0
 /**
  * Lazy loads helpers. Provides access to deprecated request properties as well.
  *
  * @param string $name Name of the property being accessed.
  * @return mixed Helper or property found at $name
  */
 public function __get($name)
 {
     if (isset($this->_helperMap[$name]) && !isset($this->{$name})) {
         $settings = array_merge((array) $this->_helperMap[$name]['settings'], array('enabled' => false));
         $this->{$name} = $this->_View->loadHelper($this->_helperMap[$name]['class'], $settings);
     }
     if (isset($this->{$name})) {
         return $this->{$name};
     }
     switch ($name) {
         case 'base':
         case 'here':
         case 'webroot':
         case 'data':
             return $this->request->{$name};
         case 'action':
             return isset($this->request->params['action']) ? $this->request->params['action'] : '';
         case 'params':
             return $this->request;
     }
 }
 function getMediaURL()
 {
     $id = $this->request->query('user_id');
     $this->loadModel('User');
     $user = $this->User->findById($id);
     $view = new View($this);
     $avatar = $view->loadHelper('Avatar');
     $img = $avatar->getMediaLink($user, array('size' => 'thumb300x150'));
     echo json_encode($img);
     exit;
 }
Example #3
0
 function ajax_upcoming()
 {
     $this->layout = 'ajax';
     $view = new View($this);
     $tz = $view->loadHelper('Tmzone');
     $today = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, GMT_DATETIME, "date");
     $this->set('today', $today);
     if (!empty($this->params['data']['projid'])) {
         $getUpcoming = $this->User->getUpcoming($this->params['data']['projid'], $today, $this->params['data']['type']);
         $this->set('nextdue', $getUpcoming);
     }
 }
 /**
  * @method public taskDownload() Create downloadable folder which will contain a .csv File and a Folder containg all the Attachment
  * @return string Returns the downloadable URL
  * @author GDR<*****@*****.**>
  */
 function taskDownload()
 {
     if (!is_dir(DOWNLOAD_TASK_PATH)) {
         mkdir(DOWNLOAD_TASK_PATH, 0777, true);
     }
     if (!is_dir(DOWNLOAD_TASK_PATH . "zipTask")) {
         mkdir(DOWNLOAD_TASK_PATH . "zipTask", 0777, true);
     }
     $caseUniqId = $this->data['caseUid'];
     //$caseUniqId = '8d082f712782302aafe8a62129f7cc24';
     $this->layout = 'ajax';
     $sorting = '';
     $ProjId = NULL;
     $ProjName = NULL;
     $curCaseNo = NULL;
     $curCaseId = NULL;
     ######## get case number from case uniq ID ################
     $getCaseNoPjId = $this->Easycase->getEasycase($caseUniqId);
     if ($getCaseNoPjId) {
         $curCaseNo = $getCaseNoPjId['Easycase']['case_no'];
         $curCaseId = $getCaseNoPjId['Easycase']['id'];
         $prjid = $getCaseNoPjId['Easycase']['project_id'];
         $is_active = intval($getCaseNoPjId['Easycase']['isactive']) ? 1 : 0;
     } else {
         //No task with uniq_id $caseUniqId
         die;
     }
     ######## Checking user_project ################
     $this->loadModel('ProjectUser');
     $cond1 = array('conditions' => array('ProjectUser.user_id' => SES_ID, 'ProjectUser.company_id' => SES_COMP, 'Project.isactive' => 1, 'Project.id' => $prjid), 'fields' => array('DISTINCT Project.id', 'Project.uniq_id', 'Project.name', 'Project.short_name'));
     $this->ProjectUser->unbindModel(array('belongsTo' => array('User')));
     $getProjId = $this->ProjectUser->find('first', $cond1);
     if ($getProjId) {
         $ProjId = $getProjId['Project']['id'];
         $projUniqId = $getProjId['Project']['uniq_id'];
         $ProjName = $getProjId['Project']['name'];
         $projShorName = $getProjId['Project']['short_name'];
     } else {
         //Session user not assigned the project $prjid
         die;
     }
     $sqlcasedata = array();
     $getPostCase = array();
     if ($ProjId && $curCaseNo) {
         //$getPostCase = $this->Easycase->query("SELECT Easycase.*, User1.name AS created_by , User2.name as updated_by , User3.name AS Assigned_to  FROM easycases as Easycase LEFT JOIN users User1 ON Easycase.user_id=User1.id LEFT JOIN users User2 ON Easycase.updated_by= User2.id LEFT JOIN users User3 ON Easycase.assign_to= User3.id WHERE Easycase.project_id='".$ProjId."' AND Easycase.case_no=".$curCaseNo." AND (Easycase.legend !=6) ORDER BY Easycase.actual_dt_created ASC");
         $getPostCase = $this->Easycase->query("SELECT Easycase.*, User1.name AS created_by , User2.name as updated_by , User3.name AS Assigned_to  FROM easycases as Easycase LEFT JOIN users User1 ON Easycase.user_id=User1.id LEFT JOIN users User2 ON Easycase.updated_by= User2.id LEFT JOIN users User3 ON Easycase.assign_to= User3.id WHERE Easycase.project_id='" . $ProjId . "' AND Easycase.case_no=" . $curCaseNo . " AND (Easycase.istype='1' OR Easycase.legend !=6) ORDER BY Easycase.actual_dt_created ASC");
         $estimated_hours = isset($getPostCase['0']['Easycase']) && !empty($getPostCase['0']['Easycase']) ? $getPostCase['0']['Easycase']['estimated_hours'] : '0.0';
         $getHours = $this->Easycase->query("SELECT SUM(hours) as hours FROM easycases as Easycase WHERE project_id='" . $ProjId . "' AND case_no=" . $curCaseNo . " AND reply_type=0");
         $hours = $getHours[0][0]['hours'];
         //		$getcompletedtask = $this->Easycase->query("SELECT completed_task  FROM easycases as Easycase WHERE project_id='".$ProjId."' AND case_no=".$curCaseNo."  and completed_task != 0 ORDER BY id DESC LIMIT 1");
         //		$completedtask  = $getcompletedtask[0]['Easycase']['completed_task'];
     } else {
         //$ProjId and $curCaseNo not found. This step should not, b'cos it handeled previously.
         die;
     }
     $view = new View();
     $cq = $view->loadHelper('Casequery');
     $frmt = $view->loadHelper('Format');
     $curdt = date('F_dS_Y', time());
     $filename = strtoupper($projShorName) . '_TASK_' . $curCaseNo . "_" . $curdt . '.csv';
     //$filename = $ProjName . "_#".$curCaseNo."_" . date("mdY", time()).'.csv';
     $folder_name = strtoupper($projShorName) . '_TASK_' . $curCaseNo . "_" . $curdt;
     if (file_exists(DOWNLOAD_TASK_PATH . $folder_name)) {
         @chmod(DOWNLOAD_TASK_PATH . $folder_name . "/attachments", 0777);
         @array_map('unlink', glob(DOWNLOAD_TASK_PATH . $folder_name . "/attachments/*"));
         @rmdir(DOWNLOAD_TASK_PATH . $folder_name . '/attachments');
         @array_map('unlink', glob(DOWNLOAD_TASK_PATH . $folder_name . "/*"));
         $isdel = rmdir(DOWNLOAD_TASK_PATH . $folder_name);
     }
     mkdir(DOWNLOAD_TASK_PATH . $folder_name, 0777, true);
     $file = fopen(DOWNLOAD_TASK_PATH . $folder_name . '/' . $filename, "w");
     $csv_output = "Title, Description, Status, Priority, Task Type, Assigned To, Created By, Last Updated By, Created On, Estimated Hours, Hours Spent";
     fputcsv($file, explode(',', $csv_output));
     foreach ($getPostCase as $key => $case_list) {
         $status = '';
         $priority = '';
         $tasktype = '';
         $taskTitle = '';
         //if(!$key) {
         if (isset($case_list['Easycase']['title']) && $case_list['Easycase']['title']) {
             $taskTitle = $case_list['Easycase']['title'];
         }
         $status = $this->Format->displayStatus($case_list['Easycase']['legend']);
         if ($case_list['Easycase']['priority'] == 2) {
             $priority = 'Low';
         } elseif ($case_list['Easycase']['priority'] == 1) {
             $priority = 'Medium';
         } elseif ($case_list['Easycase']['priority'] == 0) {
             $priority = 'High';
         }
         $types = $cq->getTypeArr($case_list['Easycase']['type_id'], $GLOBALS['TYPE']);
         if (count($types)) {
             $tasktype = $types['Type']['name'];
         }
         //}
         $arr = '';
         $arr[] = $title = str_replace('"', '""', $case_list['Easycase']['title']);
         $arr[] = $description = strip_tags(str_replace('"', '""', $case_list['Easycase']['message']));
         $arr[] = $status;
         $arr[] = $priority;
         $arr[] = $tasktype;
         if ($case_list['User3']['Assigned_to']) {
             $Assigned = $case_list['User3']['Assigned_to'];
         } else {
             $Assigned = $case_list['User1']['created_by'];
         }
         $arr[] = $Assigned;
         $arr[] = $crby = $case_list['User1']['created_by'];
         $arr[] = $updateby = $case_list['User2']['updated_by'];
         $tz = $view->loadHelper('Tmzone');
         $temp_dat = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $case_list['Easycase']['actual_dt_created'], "datetime");
         $arr[] = $crted = date('m/d/Y H:i:s', strtotime($temp_dat));
         //$arr[] = $crted =date('m/d/Y H:i:s', strtotime($case_list['Easycase']['actual_dt_created']));
         $estmthrs = '';
         $hrspent = '';
         if ($case_list['Easycase']['istype'] == 1) {
             $estmthrs = $estimated_hours;
             $hrspent = $hours;
         } else {
             $estimated_hours = '';
             $hrspent = $case_list['Easycase']['hours'];
         }
         $arr[] = $estimated_hours;
         $arr[] = $hrspent;
         $easycaseids[] = $case_list['Easycase']['id'];
         $retval = fputcsv($file, $arr);
         //$csv_output .= $title.",".$status.",".$priority.",".$tasktype.",".$description.",".$Assigned.",".$crby.",".$updateby.",".$estmthrs.",".$hrspent.",".$crted.",".$modified;
     }
     fclose($file);
     if ($retval) {
         $filesarr = ClassRegistry::init('CaseFile')->find('all', array('conditions' => array('CaseFile.easycase_id' => $easycaseids, 'CaseFile.project_id' => $ProjId, 'CaseFile.company_id' => SES_COMP)));
         if ($filesarr) {
             foreach ($filesarr as $k => $value) {
                 if ($value['CaseFile']['downloadurl']) {
                     if (!isset($fp)) {
                         $fp = fopen(DOWNLOAD_TASK_PATH . $folder_name . '/cloud.txt', 'a+');
                     }
                     fwrite($fp, "\n\t" . $value['CaseFile']['downloadurl'] . "\n");
                     $temp_url = $value['CaseFile']['downloadurl'];
                 } else {
                     if (!file_exists(DOWNLOAD_TASK_PATH . $folder_name . '/attachments')) {
                         mkdir(DOWNLOAD_TASK_PATH . $folder_name . "/attachments", 0777, true);
                     }
                     $temp_url = $frmt->generateTemporaryURL(DIR_CASE_FILES_S3 . $value['CaseFile']['file']);
                     $img = DOWNLOAD_TASK_PATH . $folder_name . "/attachments/" . $value['CaseFile']['file'];
                     $resp = file_put_contents($img, file_get_contents($temp_url));
                 }
             }
             if (isset($fp)) {
                 fclose($fp);
             }
         }
         $zipfile_name = strtoupper($projShorName) . '_TASK_' . $curCaseNo . "_" . $curdt . '.zip';
         $zipfile = DOWNLOAD_TASK_PATH . 'zipTask/' . $zipfile_name;
         $return = $this->Format->zipFile(DOWNLOAD_TASK_PATH . $folder_name, $zipfile, 1);
         if ($return) {
             if (file_exists(DOWNLOAD_TASK_PATH . $folder_name)) {
                 @array_map('unlink', glob(DOWNLOAD_TASK_PATH . $folder_name . "/attachments/*"));
                 @rmdir(DOWNLOAD_TASK_PATH . $folder_name . '/attachments');
                 @array_map('unlink', glob(DOWNLOAD_TASK_PATH . $folder_name . "/*"));
                 $isdel = rmdir(DOWNLOAD_TASK_PATH . $folder_name);
             }
             if (USE_S3 == 0) {
                 $download_url = HTTP_ROOT . DOWNLOAD_S3_TASK_PATH . $zipfile_name;
                 $this->set('downloadurl', $download_url);
             } else {
                 $s3 = new S3(awsAccessKey, awsSecretKey);
                 $s3->putBucket(DOWNLOAD_BUCKET_NAME, S3::ACL_PRIVATE);
                 $download_url = DOWNLOAD_S3_TASK_PATH . $zipfile_name;
                 $s3_download_url = "https://s3.amazonaws.com/" . DOWNLOAD_BUCKET_NAME . '/' . DOWNLOAD_S3_TASK_PATH . $zipfile_name;
                 $returnvalue = $s3->putObjectFile(DOWNLOAD_S3_TASK_PATH . $zipfile_name, DOWNLOAD_BUCKET_NAME, $download_url, S3::ACL_PUBLIC_READ);
                 if ($returnvalue) {
                     unlink(DOWNLOAD_S3_TASK_PATH . $zipfile_name);
                 }
                 $this->set('downloadurl', $s3_download_url);
             }
             $this->set('projName', $ProjName);
             $this->set('projId', $ProjId);
             $this->set('caseUid', $caseUniqId);
             $this->set('caseNum', $curCaseNo);
             $this->set('taskTitle', $taskTitle);
             $this->set('zipfilename', $zipfile_name);
         } else {
             $this->set('derror', 'Opps! Error occured in creation of zip file.');
         }
     } else {
         $this->set('derror', 'Opps! Error occured in creating the task csv file.');
     }
 }
function UsermgmtInIt(&$controller)
{
    /*
    	setting	default	time zone for your site
    */
    date_default_timezone_set("America/New_York");
    App::import('View', 'View');
    $view = new View($controller);
    $html = $view->loadHelper('Html');
    /*
    	setting	site url
    	do not edit	it
    	if you want	to edit	then for example
    	define("SITE_URL", "http://example.com/");
    */
    define("SITE_URL", $html->url('/', true));
    /*
    	set	true if	new	registrations are allowed
    */
    define("siteRegistration", true);
    /*
    	set	true if	you	want send registration mail	to user
    */
    define("sendRegistrationMail", true);
    /*
    	set	true if	you	want verify	user's email id, site will send	email confirmation link	to user's email	id
    	sett false you do not want verify user's email id, in this case	user becomes active	after registration with	out	email verification
    */
    define("emailVerification", true);
    /*
    	set	email address for sending emails
    */
    define("emailFromAddress", '*****@*****.**');
    /*
    	set	site name for sending emails
    */
    define("emailFromName", 'User Management Plugin');
    /*
    	set	login redirect url,	it means when user gets	logged in then site	will redirect to this url.
    */
    define("loginRedirectUrl", '/dashboard');
    /*
    	set	logout redirect	url, it	means when user	gets logged	out	then site will redirect	to this	url.
    */
    define("logoutRedirectUrl", '/login');
    /*
    	set	true if	you	want to	enable permissions on your site
    */
    define("PERMISSIONS", true);
    /*
    	set	true if	you	want to	check permissions for admin	also
    */
    define("ADMIN_PERMISSIONS", false);
    /*
    	set	default	group id here for registration
    */
    define("defaultGroupId", 2);
    /*
    	set	Admin group	id here
    */
    define("ADMIN_GROUP_ID", 1);
    /*
    	set	Guest group	id here
    */
    define("GUEST_GROUP_ID", 3);
    Cache::config('UserMgmt', array('engine' => 'File', 'duration' => '+3 months', 'path' => CACHE, 'prefix' => 'UserMgmt_'));
}
 function ajax_milestonelist()
 {
     $this->loadModel('Easycase');
     $view = new View($this);
     $tz = $view->loadHelper('Tmzone');
     $dt = $view->loadHelper('Datetime');
     $cq = $view->loadHelper('Casequery');
     $frmt = $view->loadHelper('Format');
     $milestone_search = $this->params['data']['file_srch'];
     $caseMenuFilters = $this->data['caseMenuFilters'];
     if ($caseMenuFilters) {
         setcookie('CURRENT_FILTER', $caseMenuFilters, COOKIE_REM, '/', DOMAIN_COOKIE, false, false);
     } else {
         setcookie('CURRENT_FILTER', $caseMenuFilters, COOKIE_REM, '/', DOMAIN_COOKIE, false, false);
     }
     $data = $this->Easycase->ajax_milestonelist($this->data, $frmt, $dt, $tz, $cq, $milestone_search);
     $this->set('resCaseProj', json_encode($data));
 }
 function startTest()
 {
     $this->View = new View(null);
     $this->TwitterGoodies = $this->View->loadHelper('TwitterKit.TwitterGoodies');
 }
Example #8
0
 /**
  * Test __get allowing access to helpers.
  *
  * @return void
  */
 public function testMagicGet()
 {
     $View = new View($this->PostsController);
     $View->loadHelper('Html');
     $this->assertInstanceOf('HtmlHelper', $View->Html);
 }
Example #9
0
 public function preview()
 {
     $this->autoRender = false;
     if ($this->request->is('post') || $this->request->is('ajax')) {
         $view = new View($this);
         $markdown = $view->loadHelper('Markdown');
         return json_encode(array('preview' => $markdown->parse($this->request->data['Preview'])));
     }
     return json_encode(array('preview' => 'no dice'));
 }
Example #10
0
 function login()
 {
     if ($this->Session->check('mobile_user') && intval($this->Session->read('mobile_user'))) {
         $this->layout = 'mobile';
         $this->view = 'mobile_login';
     } else {
         $this->layout = 'register';
     }
     if (!empty($this->request->data)) {
         if ($this->Auth->login()) {
             if ($this->Auth->user('is_activated')) {
                 if ($this->Auth->user('type') == USER_TYPE_TENANT) {
                     if ($this->Auth->user('property_id') > 0) {
                         // If property no longer active, then we must redirect
                         $this->loadModel('Property');
                         $this->Property->contain();
                         $userProp = $this->Property->findById($this->Auth->user('property_id'));
                         if ($userProp['Property']['active'] == 0) {
                             $this->redirect(array('controller' => 'Users', 'action' => 'propertydisabled', $this->User->id));
                         }
                     } else {
                         /*
                          *  If active user with no property_id they must have been removed from property
                          */
                         $this->Session->setFlash('You are no longer assigned to a property.  Please request a new property now.', 'flash_bad');
                         $redir_id = $this->Auth->User('id');
                         $this->Auth->logout();
                         $this->redirect(array('controller' => 'Users', 'action' => 'residentsearch', Security::cipher($redir_id, Configure::read('Security.salt2'))));
                     }
                 }
                 $this->redirect($this->Auth->redirect());
             } elseif (!$this->Auth->user('is_activated') && $this->Auth->user('invitebyemail')) {
                 $this->User->id = $this->Auth->user('id');
                 $this->User->saveField('is_activated', true);
                 /*
                  * Update the unit to occupied after the invite is sent.
                  */
                 if ($this->Auth->user('unit_id') > 0) {
                     $this->loadModel('Unit');
                     $this->Unit->id = $this->Auth->user('unit_id');
                     $this->Unit->saveField('occupied', 'Yes');
                 }
                 $this->redirect($this->Auth->redirect());
             } else {
                 $view = new View($this);
                 $html = $view->loadHelper('Html');
                 $resendLink = $html->link('Click Here', array('controller' => 'Users', 'action' => 'resendactivation', $this->Auth->user('id')));
                 /*
                  * previoustenant field can have following values
                  *  - 0 not a previous tenant
                  *  - 1 a previous tenant
                  *  - 2 a previous tenant awaiting a new activation
                  */
                 if ($this->Auth->user('previoustenant') == 1 && $this->Auth->user('type') == USER_TYPE_TENANT) {
                     /*
                      * Previous tenant, currently inactive, who is trying to log back in - so need to send
                      *  to page 2 of the tenant sign up process 
                      */
                     $data = array();
                     $data['User']['id'] = $this->Auth->User('id');
                     /* Set to 2 so we can differentiate - i.e. know they came through this way already */
                     //$data['User']['previoustenant'] = '2';
                     $data['User']['property_id'] = '0';
                     $data['User']['unit_id'] = '0';
                     $data['User']['requested_unit'] = '0';
                     $data['User']['activation_key'] = $this->User->genActivationHash();
                     $this->User->set($data);
                     if ($this->User->save($data, true, array('requested_unit', 'activation_key', 'property_id', 'unit_id'))) {
                         //debug($data);
                         $redir_id = $this->Auth->User('id');
                         $this->Auth->logout();
                         $this->redirect(array('controller' => 'Users', 'action' => 'residentsearch', Security::cipher($redir_id, Configure::read('Security.salt2'))));
                     } else {
                         $this->Session->setFlash('Error Signing Up. Please contact system admin.', 'flash_bad');
                     }
                 } else {
                     $this->Auth->logout();
                     $this->Session->setFlash('Sorry, your account is not yet activated.', 'flash_bad');
                     $this->redirect($this->Auth->redirect());
                 }
             }
         } else {
             $this->Session->setFlash('Invalid username or password.', 'flash_bad');
         }
     }
 }
 /**
  * returns dataTables compatible array - just json_encode the resulting aray
  * @param object $controller optional
  * @param object $model optional
  * @return array
  */
 public function getResponse($controller = null, $model = null)
 {
     /**
      * it is no longer necessary to pass in a controller or model
      * this is handled in the initialize method
      * $controller is disregarded.
      * $model is only necessary if you are using a model from a different controller such as if you are in 
      * a CustomerController but your method is displaying data from an OrdersModel.
      */
     if ($model != null) {
         if (is_string($model)) {
             $this->model = $this->controller->{$model};
         } else {
             $this->model = $model;
             unset($model);
         }
     }
     $conditions = isset($this->controller->paginate['conditions']) ? $this->controller->paginate['conditions'] : null;
     $isFiltered = false;
     if (!empty($conditions)) {
         $isFiltered = true;
     }
     // check for ORDER BY in GET request
     if (isset($this->controller->request->query) && isset($this->controller->request->query['iSortCol_0'])) {
         $orderBy = $this->getOrderByStatements();
         if (!empty($orderBy)) {
             $this->controller->paginate = array_merge($this->controller->paginate, array('order' => $orderBy));
         }
     }
     // check for WHERE statement in GET request
     if (isset($this->controller->request->query) && !empty($this->controller->request->query['sSearch'])) {
         $conditions = $this->getWhereConditions();
         if (!empty($this->controller->paginate['contain'])) {
             $this->controller->paginate = array_merge_recursive($this->controller->paginate, array('contain' => $conditions));
         } else {
             $this->controller->paginate = array_merge_recursive($this->controller->paginate, array('conditions' => $conditions));
         }
         $isFiltered = true;
     }
     // @todo avoid multiple queries for finding count, maybe look into "SQL CALC FOUND ROWS"
     // get full count
     $total = $this->model->find('count');
     $parameters = $this->controller->paginate;
     if ($isFiltered) {
         $filteredTotal = $this->model->find('count', $parameters);
     }
     $limit = '';
     // set sql limits
     if (isset($this->controller->request->query['iDisplayStart']) && $this->controller->request->query['iDisplayLength'] != '-1') {
         $start = $this->controller->request->query['iDisplayStart'];
         $length = $this->controller->request->query['iDisplayLength'];
         $parameters['limit'] = $limit = "{$start},{$length}";
     }
     // execute sql select
     //debug($parameters);
     $data = $this->model->find('all', $parameters);
     //debug($data);
     // dataTables compatible array
     $response = array('sEcho' => isset($this->controller->request->query['sEcho']) ? intval($this->controller->request->query['sEcho']) : 1, 'iTotalRecords' => $total, 'iTotalDisplayRecords' => $isFiltered === true ? $filteredTotal : $total, 'aaData' => array());
     // return data
     if (!$data) {
         return $response;
     } else {
         // failsafe for null records...
         if ($data[0][$this->model->name]["id"] == null) {
             return $response;
         }
         $count = 0;
         foreach ($data as $i) {
             $tmp = $this->getDataRecursively($i);
             if ($this->emptyElements > 0) {
                 $tmp = array_pad($tmp, count($tmp) + $this->emptyElements, '');
             }
             $response['aaData'][$count] = array_values($tmp);
             if (!empty($this->showActions)) {
                 $view = new View($this->controller);
                 $html = $view->loadHelper('Html');
                 $id = $response['aaData'][$count][$this->showActions["idCol"]];
                 $actions = "";
                 if (!empty($this->showActions["oppty"])) {
                     $actions = $actions . $html->link('<i></i>', array('controller' => 'quotes', 'action' => 'add', "0", "0", $id, "0"), array('escape' => false, 'class' => 'glyphicons coins qtips', 'data-title' => 'Generar Cotizacion'));
                 }
                 if (!empty($this->showActions["quote"])) {
                     $actions = $actions . $html->link('<i></i>', array('controller' => 'Orders', 'action' => 'add', "0", "0", $id, "Quote"), array('escape' => false, 'class' => 'glyphicons shopping_cart qtips', 'data-title' => 'Generar Pedido'));
                     $actions = $actions . $html->link('<i></i>', array('controller' => 'quotes', 'action' => 'viewPdf', $id), array('escape' => false, 'class' => 'glyphicons file qtips', 'data-title' => 'Generar PDF', 'target' => '_blank'));
                 }
                 if (!empty($this->showActions["order"])) {
                     $actions = $actions . $html->link('<i></i>', array('controller' => 'invoices', 'action' => 'add', "0", $id), array('escape' => false, 'class' => 'glyphicons usd qtips', 'data-title' => 'Generar Factura'));
                 }
                 //$actions = $actions . $html->link('<i></i>', array('action' => 'edit', $id ), array('escape' => false, 'class'=>'glyphicons pencil qtips','data-title'=>'Editar'));
                 $actions = $actions . $html->link('<i></i>', array('action' => 'delete', $id), array('escape' => false, 'class' => 'glyphicons bin qtips', 'data-title' => 'Cancelar'), __('Estas seguro de cancelar el registro # %s?', $id));
                 $response['aaData'][$count][] = $actions;
             }
             if ($this->columnsStyle) {
                 foreach ($this->columnsStyle as $c) {
                     $response['aaData'][$count]['style'] = $c;
                 }
             }
             $count++;
         }
     }
     return $response;
 }
Example #12
0
 /**
  * menus
  *
  * @return void
  * @author apple
  **/
 function getmenus($type = 'vmenu', $id = '', $router = 0)
 {
     $baseURL = Router::url("/admin/wc/{$id}/");
     $menu = array('hmenu' => array("我的工作台" => array('url' => "", 'icon' => "icon-desktop", 'child' => array('网站信息' => array('url' => Router::url(array('controller' => "admin", 'action' => "wBasic")), 'icon' => "icon-double-angle-right", 'FIsAdmin' => 1), '基本信息' => array('url' => Router::url(array('controller' => "admin", 'action' => "basic")), 'icon' => "icon-double-angle-right"), '公众账号管理' => array('url' => Router::url(array('controller' => "admin", 'action' => "index")), 'icon' => "icon-double-angle-right", 'action' => array('添加公众账号' => array('url' => Router::url(array('controller' => "admin", 'action' => "webchatAdd")), 'icon' => "icon-double-angle-right"), '编辑公众账号' => array('url' => Router::url(array('controller' => "admin", 'action' => "webchatEdit")), 'icon' => "icon-double-angle-right"))), '修改密码' => array('url' => Router::url(array('controller' => "admin", 'action' => "repwd")), 'icon' => "icon-double-angle-right")), 'open' => 1, 'active' => 1)), 'vmenu' => array("工作台" => array('url' => "{$baseURL}center", 'icon' => "icon-dashboard", 'FIsActive' => 0), "系统设置" => array('url' => "", 'icon' => "icon-desktop", 'child' => array('账号设置' => array('url' => "{$baseURL}sAroz", 'icon' => "icon-double-angle-right"), '默认设置' => array('url' => "{$baseURL}bCtg", 'icon' => "icon-double-angle-right"))), "自动回复" => array('url' => "", 'icon' => "icon-edit", 'child' => array('被关注回复' => array('url' => "{$baseURL}bFllow", 'icon' => "icon-double-angle-right"), '无匹配回复' => array('url' => "{$baseURL}bMch", 'icon' => "icon-double-angle-right"), '关键字回复' => array('url' => "{$baseURL}bKds", 'icon' => "icon-double-angle-right"), 'LBS回复' => array('FIsActive' => 0, 'url' => "{$baseURL}bLbs", 'icon' => "icon-double-angle-right"))), "高级设置" => array('url' => "", 'icon' => "icon-cogs", 'child' => array('自定义菜单' => array('url' => "{$baseURL}sMenu", 'icon' => "icon-double-angle-right"), '二维码营销' => array('url' => "{$baseURL}sCode", 'icon' => "icon-double-angle-right"), '语音识别' => array('url' => "{$baseURL}sVoice", 'icon' => "icon-double-angle-right"), '粉丝管理' => array('url' => "{$baseURL}sFans", 'icon' => "icon-double-angle-right"), '微客服' => array('url' => "{$baseURL}sCuts", 'icon' => "icon-double-angle-right")), 'FIsActive' => 0), "素材库" => array('url' => "", 'icon' => "icon-picture", 'child' => array('文本' => array('url' => "{$baseURL}mTxt", 'icon' => "icon-double-angle-right", 'FIsActive' => 0), '图文' => array('url' => "{$baseURL}mPic", 'icon' => "icon-double-angle-right"), '图片' => array('url' => "{$baseURL}mPic", 'icon' => "icon-double-angle-right", 'FIsActive' => 0), '语音' => array('url' => "{$baseURL}mPic", 'icon' => "icon-double-angle-right", 'FIsActive' => 0), '图文集' => array('url' => "{$baseURL}mPicGary", 'icon' => "icon-double-angle-right", 'FIsActive' => 0), '幻灯片' => array('url' => "{$baseURL}mSlide", 'icon' => "icon-double-angle-right", 'FIsActive' => 0), '多媒体文件' => array('url' => "{$baseURL}mFile", 'icon' => "icon-double-angle-right", 'FIsActive' => 0))), "自定义菜单" => array('url' => "", 'icon' => "icon-list", 'child' => array('菜单设置' => array('url' => "{$baseURL}mFields", 'icon' => "icon-double-angle-right"))), "互动应用" => array('url' => "", 'icon' => "icon-hdd", 'FIsActive' => 0, 'child' => array('智能机器人' => array('url' => "{$baseURL}hRobot", 'icon' => "icon-double-angle-right"), '应用中心' => array('url' => "{$baseURL}hApp", 'icon' => "icon-double-angle-right"))), "统计" => array('url' => "", 'icon' => "icon-list-alt", 'child' => array('用户分析' => array('url' => "{$baseURL}sUser", 'icon' => "icon-double-angle-right"), '消息分析' => array('url' => "{$baseURL}sMsg", 'icon' => "icon-double-angle-right"), '图文分析' => array('url' => "{$baseURL}sImtxt", 'icon' => "icon-double-angle-right")), 'FIsActive' => 0), "我的APP" => array('url' => "", 'icon' => "icon-laptop", 'child' => array('APP设置' => array('url' => "{$baseURL}aSet", 'icon' => "icon-double-angle-right"), '应用模板' => array('url' => "{$baseURL}aLayout", 'icon' => "icon-double-angle-right"), '自定义模块' => array('url' => "{$baseURL}aMods", 'icon' => "icon-double-angle-right"), 'DIY界面' => array('url' => "{$baseURL}aDiyAps", 'icon' => "icon-double-angle-right"), '绑定域名' => array('url' => "{$baseURL}aDomain", 'icon' => "icon-double-angle-right"), '第三方组件' => array('url' => "{$baseURL}aCmet", 'icon' => "icon-double-angle-right")), 'FIsActive' => 0)));
     $view = new View();
     $main = $view->loadHelper('Main');
     $vmenu = $main->menuSearch($menu[$type], $type, $router);
     return $vmenu;
 }
 public function exportCSV(Model $Model, $data = array(), $return = false)
 {
     $debug = 0;
     if (array_key_exists('fileName', $data)) {
         $fileName = $data['fileName'];
     }
     if (array_key_exists('fieldNames', $data)) {
         $fieldNames = $data['fieldNames'];
     }
     if (array_key_exists('data', $data)) {
         $fieldData = $data['data'];
     }
     if (array_key_exists('title', $data)) {
         $title = $data['title'];
     }
     if (!isset($fieldNames) || !isset($data)) {
         die('error: p');
     }
     if (!isset($fileName)) {
         $fileName = $Model->alias;
         $nowTime = time();
         $nowTime = date('Y-m-d H:i:s');
         $fileName .= ' - ' . $nowTime;
     }
     if (!$debug) {
         $view = new View($Model->controller);
     }
     if (!$debug) {
         $csv = $view->loadHelper('Csv');
     }
     if (!$debug) {
         $csv->newCsv($fileName . '.csv', $return);
     }
     if (isset($title)) {
         foreach ($title as $key => $value) {
             if (!$debug) {
                 $csv->setRow($value);
             }
         }
         if (!$debug) {
             $csv->setRow(array(''));
         }
     }
     if (!$debug) {
         $csv->setRow(array_values($fieldNames));
     }
     $keys = array_keys($fieldNames);
     foreach ($keys as $i => $key) {
         $keys[$i] = explode('.', $key);
     }
     foreach ($fieldData as $data) {
         $row = array();
         foreach ($keys as $key) {
             $model = $key[0];
             $field = $key[1];
             $row[] = $data[$model][$field];
         }
         if (!$debug) {
             $csv->setRow($row);
         }
     }
     if ($return) {
         return $csv->get_file_contents();
     }
     if (!$debug) {
         $csv->output();
     }
     exit;
 }
 public function moreconversation()
 {
     if ($this->Session->read('user.id') == '') {
         $this->redirect(array('controller' => 'user', 'action' => 'login'));
     }
     $this->autoRender = false;
     $start = 0;
     $end = $this->showMoreDisplay();
     $listConversation = $this->Message->conversationListing($this->Session->read('user.id'), $start, $end, $this->sanitize($this->request->data['id']));
     $html = '';
     $conversation = array();
     $endId = 0;
     $view = new View($this);
     $htmlHelper = $view->loadHelper('Html');
     foreach ($listConversation as $ck => $cv) {
         $endId = $cv['message']['id'];
         $thisConversation = array();
         $thisConversation['content'] = $this->desanitize($cv['message']['content']);
         $thisConversation['created'] = $cv['message']['created'];
         $thisConversation['message_id'] = $cv['message']['id'];
         if ($this->Session->read('user.id') != $cv['message']['from_id']) {
             $thisConversation['id'] = $cv['message']['from_id'];
             $thisConversation['name'] = $cv['from_users']['from_users_name'];
             $thisConversation['image'] = $cv['from_users']['from_users_image'];
             if ($thisConversation['image'] == '') {
                 $thisConversation['image'] = 'user.png';
             }
         } else {
             $thisConversation['id'] = $cv['message']['to_id'];
             $thisConversation['name'] = $cv['to_users']['to_users_name'];
             $thisConversation['image'] = $cv['to_users']['to_users_image'];
             if ($thisConversation['image'] == '') {
                 $thisConversation['image'] = 'user.png';
             }
         }
         $html .= '<div id="conversation-' . $thisConversation['message_id'] . '">';
         $html .= '<table>';
         $html .= '<tr>';
         $html .= '<td class="conversation-profile-picture profile-picture-display">';
         $html .= '<a href="' . $htmlHelper->url(array('controller' => 'user', 'action' => 'profile', $thisConversation['id']), true) . '">';
         $html .= $htmlHelper->image($thisConversation['image'], array('width' => '128', 'height' => '128'));
         $html .= '</a>';
         $html .= '</td>';
         $html .= '<td class="conversation-details">';
         $html .= '<a href="' . $htmlHelper->url(array('controller' => 'message', 'action' => 'details', $thisConversation['message_id']), true) . '">';
         $html .= '<div class="conversation-message">' . $thisConversation['content'] . '</div>';
         $html .= '</a>';
         $html .= '<div>';
         $html .= '<div class="conversation-delete"><a class="link-conversation-delete" data-id="' . $thisConversation['message_id'] . '" href="javascript:;">Delete</a></div>';
         $html .= '<div class="conversation-date">' . date('Y/m/d H:i', strtotime($thisConversation['created'])) . '</div>';
         $html .= '</div>';
         $html .= '</td>';
         $html .= '</tr>';
         $html .= '</table>';
         $html .= '</div>';
     }
     $this->response->type('json');
     echo json_encode(array('status' => $html != '' ? true : false, 'html' => $html, 'id' => $endId));
 }
Example #15
0
 function startTest()
 {
     $View = new View(null);
     $this->Twitter = $View->loadHelper('TwitterKit.Twitter');
 }
Example #16
0
 /**
  * Third party login method
  */
 public function tplogin()
 {
     if (!Configure::read('Webzash.ThirdPartyLogin')) {
         $this->redirect(array('plugin' => 'webzash', 'controller' => 'wzusers', 'action' => 'login'));
     }
     $this->set('title_for_layout', __d('webzash', 'User Login'));
     $this->layout = 'user';
     $view = new View($this);
     $this->Html = $view->loadHelper('Html');
     $this->Wzuser->useDbConfig = 'wz';
     $this->Wzsetting->useDbConfig = 'wz';
     /* on POST */
     if ($this->request->is('post') || $this->request->is('put')) {
         $tpauth = new TPAuth(Configure::read('Webzash.ThirdPartyLoginSystem'));
         $login_status = $tpauth->checkPassword($this->request->data['Wzuser']['username'], $this->request->data['Wzuser']['password']);
         if ($login_status) {
             $wzuser = $this->Wzuser->find('first', array('conditions' => array('username' => $this->request->data['Wzuser']['username'])));
             $user_data = array();
             if ($wzuser) {
                 $user_data = array('id' => $wzuser['Wzuser']['id'], 'username' => $wzuser['Wzuser']['username'], 'role' => $wzuser['Wzuser']['role']);
             } else {
                 /* Disable validations for fullname and email */
                 $this->Wzuser->validate['fullname'] = array();
                 $this->Wzuser->validate['email'] = array();
                 $user_details = $tpauth->getUserDetails();
                 $new_user['Wzuser'] = array();
                 /* If user not found create a account */
                 if ($user_details['status'] == TRUE) {
                     /* Get user details from tpauth library */
                     $new_user['Wzuser'] = array('username' => $user_details['username'], 'password' => '*', 'fullname' => $user_details['fullname'], 'email' => $user_details['email'], 'timezone' => 'UTC', 'role' => 'guest', 'status' => 0, 'verification_key' => '', 'email_verified' => 0, 'admin_verified' => 0, 'retry_count' => 0, 'all_accounts' => 0);
                 } else {
                     /* Get user details from webzash */
                     $new_user['Wzuser'] = array('username' => $this->request->data['Wzuser']['username'], 'password' => '*', 'fullname' => '', 'email' => '', 'timezone' => 'UTC', 'role' => 'guest', 'status' => 0, 'verification_key' => '', 'email_verified' => 0, 'admin_verified' => 0, 'retry_count' => 0, 'all_accounts' => 0);
                 }
                 /* Create user */
                 $this->Wzuser->create();
                 if (!$this->Wzuser->save($new_user)) {
                     $this->Session->setFlash(__d('webzash', 'Failed to create user.'), 'danger');
                     return;
                 }
                 $user_data = array('id' => $this->Wzuser->id, 'username' => $this->Wzuser->username, 'role' => $this->Wzuser->role);
             }
             $this->Auth->login($user_data);
             $wzsetting = $this->Wzsetting->findById(1);
             if (empty($wzsetting['Wzsetting']['enable_logging'])) {
                 $this->Session->write('Wzsetting.enable_logging', 0);
             } else {
                 $this->Session->write('Wzsetting.enable_logging', 1);
             }
             if (empty($wzsetting['Wzsetting']['row_count'])) {
                 $this->Session->write('Wzsetting.row_count', 10);
             } else {
                 $this->Session->write('Wzsetting.row_count', $wzsetting['Wzsetting']['row_count']);
             }
             if (empty($wzsetting['Wzsetting']['drcr_toby'])) {
                 $this->Session->write('Wzsetting.drcr_toby', 'drcr');
             } else {
                 $this->Session->write('Wzsetting.drcr_toby', $wzsetting['Wzsetting']['drcr_toby']);
             }
             if ($this->Auth->user('role') == 'admin') {
                 return $this->redirect(array('plugin' => 'webzash', 'controller' => 'admin', 'action' => 'index'));
             } else {
                 return $this->redirect($this->Auth->redirectUrl());
             }
         } else {
             $this->Session->setFlash(__d('webzash', 'Login failed. Please, try again.'), 'danger');
         }
     }
 }
Example #17
0
 function hours_linechart()
 {
     $this->layout = 'ajax';
     $this->loadModel('Easycase');
     $before = date('Y-m-d', strtotime($this->data['sdate']));
     $to = date('Y-m-d', strtotime($this->data['edate']));
     $days = (strtotime($to) - strtotime($before)) / (60 * 60 * 24);
     $proj_id = $this->data['pjid'];
     $x = floor($days);
     if ($x < 7) {
         $interval = 1;
     } elseif ($x > 80) {
         $interval = ceil($x / 10);
     } else {
         $interval = 7;
     }
     $this->set('tinterval', $interval);
     $view = new View($this);
     $tz = $view->loadHelper('Tmzone');
     $dt_arr = array();
     $dts_arr = array();
     for ($i = 0; $i <= $x; $i++) {
         $m = " +" . $i . "day";
         $dt = date('Y-m-d', strtotime(date("Y-m-d", strtotime($before)) . $m));
         $dts = date('M d, Y', strtotime(date("Y-m-d H:i:s", strtotime($before)) . $m));
         $times = explode(" ", GMT_DATETIME);
         array_push($dt_arr, $dt);
         array_push($dts_arr, $dts);
     }
     $this->set('dt_arr', json_encode($dts_arr));
     $cond = "";
     if (!empty($this->data['sdate'])) {
         $dtt = date('Y-m-d', strtotime($this->data['sdate']));
         $cond .= " AND DATE(actual_dt_created) >= '" . $dt_arr[0] . "' ";
     }
     if (!empty($this->data['edate'])) {
         $dtt = date('Y-m-d', strtotime($this->data['edate']));
         $cond .= " AND DATE(actual_dt_created) <= '" . $dt_arr[$x] . "' ";
     }
     if (!empty($this->data['pjid'])) {
         $cond .= " AND project_id = '" . $proj_id . "' ";
     }
     if (!empty($this->data['type_id'])) {
         $cond .= " AND type_id = '" . $this->data['type_id'] . "'";
     }
     if (isset($this->data['dtsearch'])) {
         $this->_save_report(2);
     }
     $sql = "SELECT Users.name as devname ,Easycases.case_no,Easycases.project_id,Easycases.user_id,Easycases.hours,Easycases.actual_dt_created AS cdate FROM easycases as Easycases,users as Users WHERE Users.id = Easycases.user_id AND Easycases.project_id!=0 AND Easycases.reply_type=0 " . $cond . "";
     $easycase = $this->Easycase->query($sql);
     if (!empty($easycase)) {
         foreach ($easycase as $k => $v) {
             $name[] = $v['Users']['devname'];
             $cdts = $tz->GetDateTime(SES_TIMEZONE, TZ_GMT, TZ_DST, TZ_CODE, $v['Easycases']['cdate'], "date");
             $reportArr[$cdts]['name'] = $v['Users']['devname'];
             $reportArr[$cdts][$v['Users']['devname']]['hour'][] = $v['Easycases']['hours'];
         }
         foreach ($dt_arr as $key => $date) {
             foreach ($name as $nm) {
                 if (array_key_exists($date, $reportArr)) {
                     if (!empty($reportArr[$date][$nm]['hour'])) {
                         $hrspent = array_sum($reportArr[$date][$nm]['hour']);
                     } else {
                         $hrspent = 0;
                     }
                 } else {
                     $hrspent = 0;
                 }
                 $hourspent[$date][$nm] = (double) $hrspent;
             }
         }
         $uname = '';
         foreach ($hourspent as $key => $value) {
             foreach ($value as $nm => $hr) {
                 $userArr[$nm][] = $hr;
             }
         }
         foreach ($userArr as $knm => $vhr) {
             $carr[] = array('name' => $knm, 'data' => $vhr);
         }
         $this->set('carr', json_encode($carr));
     } else {
         print "<div class='fl'><font color='red' size='2px'>No data for this date range & project.</font></div>";
         exit;
     }
 }
Example #18
0
 /**
  * undocumented function
  *
  * @return void
  * @author niancode
  **/
 function getMenuApi($webchat)
 {
     $newarr = array();
     $data = $this->getDataList($webchat, null, null, 1);
     foreach ($data as $key => $value) {
         $type = $this->checkType($value['url']);
         $newarr['button'][$key]['type'] = $type['type'];
         $newarr['button'][$key]['name'] = $value['name'];
         $newarr['button'][$key][$type['key']] = $value['url'];
         if (is_array($value['children'])) {
             foreach ($value['children'] as $k => $v) {
                 $type = $this->checkType($v['url']);
                 $newarr['button'][$key]['sub_button'][$k]['type'] = $type['type'];
                 $newarr['button'][$key]['sub_button'][$k]['name'] = $v['name'];
                 $newarr['button'][$key]['sub_button'][$k][$type['key']] = $v['url'];
             }
         }
     }
     $view = new View();
     $main = $view->loadHelper('Main');
     $json = $main->ch_json_encode($newarr);
     // echo '<pre>';print_r($newarr);exit;
     return $json;
 }
Example #19
0
 public function search()
 {
     $this->autoRender = false;
     if ($this->request->is(array('post'))) {
         $view = new View($this);
         $html = $view->loadHelper('Html');
         $users = $this->Users->searchByName($this->sanitize($this->request->data['q']));
         $response = array();
         foreach ($users as $userKey => $userValue) {
             $profilePicture = 'user.png';
             if ($userValue['users']['image'] != '') {
                 $profilePicture = $userValue['users']['image'];
             }
             if ($this->Session->read('user.id') != $userValue['users']['id']) {
                 $thisUser = array('id' => $userValue['users']['id'], 'name' => $this->desanitize($userValue['users']['name']), 'picture' => $html->image($profilePicture, array('width' => '32', 'height' => '32')));
                 $response[] = $thisUser;
             }
         }
         $this->response->type('json');
         echo json_encode(array('recipient' => $response));
     }
 }