/**
  * Get efforts. 
  * 
  * @param  string $account 
  * @param  int    $date 
  * @param  string $project 
  * @access public
  * @return void
  */
 public function getEfforts($account = 'all', $date, $project = '', $begin = '', $end = '')
 {
     $this->loadModel('todo');
     $efforts = array();
     if ($date == 'today') {
         $begin = $this->todo->today();
         $end = $begin;
     } elseif ($date == 'thisweek') {
         extract($this->todo->getThisWeek());
     } elseif ($date == 'lastweek') {
         extract($this->todo->getLastWeek());
     } elseif ($date == 'thismonth') {
         extract($this->todo->getThisMonth());
     } elseif ($date == 'lastmonth') {
         extract($this->todo->getLastMonth());
     } elseif ($date == 'select') {
         if ($begin == '') {
             $begin = helper::today();
         }
         if ($end == '') {
             $end = helper::today();
         }
     } elseif ($date == 'all') {
         $begin = '1970-01-01';
         $end = '2109-01-01';
     } else {
         $begin = $end = $date;
     }
     $efforts = $this->dao->select('*')->from(TABLE_SUNEFFORTEVERYDAY)->where('account')->eq($this->app->user->account)->andWhere("date >= '{$begin}'")->andWhere("date <= '{$end}'")->beginIF($project != '')->andWhere('project')->eq($project)->fi()->beginIF($account != 'all')->andWhere('account')->eq($account)->fi()->fetchAll('id');
     return $efforts;
 }
Exemple #2
0
 /**
  * Todos of a user. 
  * 
  * @param  string $account 
  * @param  string $type         the todo type, today|lastweek|thisweek|all|undone, or a date.
  * @param  string $status 
  * @param  string $orderBy 
  * @param  int    $recTotal 
  * @param  int    $recPerPage 
  * @param  int    $pageID 
  * @access public
  * @return void
  */
 public function todo($account, $type = 'today', $status = 'all', $orderBy = 'date,status,begin', $recTotal = 0, $recPerPage = 20, $pageID = 1)
 {
     /* Set thie url to session. */
     $uri = $this->app->getURI(true);
     $this->session->set('todoList', $uri);
     $this->session->set('bugList', $uri);
     $this->session->set('taskList', $uri);
     /* Load pager. */
     $this->app->loadClass('pager', $static = true);
     $pager = pager::init($recTotal, $recPerPage, $pageID);
     /* Append id for secend sort. */
     $sort = $this->loadModel('common')->appendOrder($orderBy);
     /* Get user, totos. */
     $user = $this->user->getById($account);
     $account = $user->account;
     $todos = $this->todo->getList($type, $account, $status, 0, $pager, $sort);
     $date = (int) $type == 0 ? helper::today() : $type;
     /* set menus. */
     $this->lang->set('menugroup.user', 'company');
     $this->view->userList = $this->user->setUserList($this->user->getPairs('noempty|noclosed|nodeleted'), $account);
     $this->view->title = $this->lang->user->common . $this->lang->colon . $this->lang->user->todo;
     $this->view->position[] = $this->lang->user->todo;
     $this->view->tabID = 'todo';
     $this->view->date = $date;
     $this->view->todos = $todos;
     $this->view->user = $user;
     $this->view->account = $account;
     $this->view->type = $type;
     $this->view->status = $status;
     $this->view->orderBy = $orderBy;
     $this->view->pager = $pager;
     $this->display();
 }
Exemple #3
0
 /**
  * Create json data of single charts
  * @param  array $sets
  * @param  array $dateList
  * @return string the json string
  */
 public function createSingleJSON($sets, $dateList)
 {
     $today = helper::today();
     $data = '[';
     foreach ($dateList as $i => $date) {
         $date = date('Y-m-d', strtotime($date));
         // $data .= isset($sets[$date]) ? "{$sets[$date]->value}," : "'',";
         if ($date <= $today) {
             $data .= isset($sets[$date]) ? "{$sets[$date]->value}," : "'',";
         }
     }
     $data = rtrim($data, ',');
     $data .= ']';
     return $data;
 }
Exemple #4
0
 /**
  * AJAX: get upload request from the web editor.
  * 
  * @access public
  * @return void
  */
 public function ajaxUpload()
 {
     $file = $this->file->getUpload('imgFile');
     $file = $file[0];
     if ($file) {
         if (@move_uploaded_file($file['tmpname'], $this->file->savePath . $file['pathname'])) {
             $url = $this->file->webPath . $file['pathname'];
             $file['addedBy'] = $this->app->user->account;
             $file['addedDate'] = helper::today();
             unset($file['tmpname']);
             $this->dao->insert(TABLE_FILE)->data($file)->exec();
             die(json_encode(array('error' => 0, 'url' => $url)));
         } else {
             $error = strip_tags(sprintf($this->lang->file->errorCanNotWrite, $this->file->savePath, $this->file->savePath));
             die(json_encode(array('error' => 1, 'message' => $error)));
         }
     }
 }
 /**
  * Save upload.
  * 
  * @param  string $objectType 
  * @param  string $objectID 
  * @param  string $extra 
  * @access public
  * @return array
  */
 public function saveUpload($objectType = '', $objectID = '', $extra = '')
 {
     $fileTitles = array();
     $now = helper::today();
     $files = $this->getUpload();
     foreach ($files as $id => $file) {
         move_uploaded_file($file['tmpname'], $this->savePath . $file['pathname']);
         $file['objectType'] = $objectType;
         $file['objectID'] = $objectID;
         $file['addedBy'] = $this->app->user->account;
         $file['addedDate'] = $now;
         $file['extra'] = $extra;
         unset($file['tmpname']);
         $this->dao->insert(TABLE_FILE)->data($file)->exec();
         $fileTitles[$this->dao->lastInsertId()] = $file['title'];
     }
     return $fileTitles;
 }
Exemple #6
0
 public function manageMembers($planID)
 {
     extract($_POST);
     // $accounts = array_unique($accounts);
     foreach ($accounts as $key => $account) {
         if (empty($account)) {
             continue;
         }
         $member = new stdclass();
         $member->role = $roles[$key];
         $member->days = $days[$key];
         $member->hours = $hours[$key];
         $member->project = $projs[$key];
         $member->plan = (int) $planID;
         $member->account = $account;
         $member->join = helper::today();
         $this->dao->delete()->from(TABLE_TEAM)->where('plan')->eq($member->plan)->andWhere('account')->eq($account)->andWhere('project')->eq('0')->exec();
         //$this->dao->delete()->from(TABLE_TEAM)
         //     ->where('project')->eq($member->project)
         //     ->andWhere('account')->eq($account)->exec();
         $this->dao->insert(TABLE_TEAM)->data($member)->exec();
         // $mode = $modes[$key];
         // if($mode == 'update')
         // {
         // 	$this->dao->update(TABLE_TEAM)
         // 	->data($member)
         // 	->where('plan')->eq((int)$planID)
         // 	->andWhere('account')->eq($account)
         // 	->exec();
         // }
         // else
         // {
         // 	// $member->plan = (int)$planID;
         // 	$member->account = $account;
         // 	$member->join    = helper::today();
         // 	$this->dao->insert(TABLE_TEAM)->data($member)->exec();
         // }
     }
 }
Exemple #7
0
 /** 
  * Get order list.
  * 
  * @param  string  $mode 
  * @param  mix     $param 
  * @param  string  $orderBy 
  * @param  object  $pager 
  * @access public
  * @return array
  */
 public function getList($mode = 'all', $param = null, $owner = '', $orderBy = 'id_desc', $pager = null)
 {
     $customerIdList = $this->loadModel('customer')->getCustomersSawByMe();
     if (empty($customerIdList)) {
         return array();
     }
     $products = $this->loadModel('product')->getPairs();
     $this->app->loadClass('date', $static = true);
     $thisMonth = date::getThisMonth();
     $thisWeek = date::getThisWeek();
     /* Process search condition. */
     if ($this->session->orderQuery == false) {
         $this->session->set('orderQuery', ' 1 = 1');
     }
     $orderQuery = $this->loadModel('search', 'sys')->replaceDynamic($this->session->orderQuery);
     if (strpos($orderBy, 'status') !== false) {
         $orderBy .= ', closedReason';
     }
     if (strpos($orderBy, 'id') === false) {
         $orderBy .= ', id_desc';
     }
     $userList = $this->loadModel('user')->getSubUsers($this->app->user);
     $orders = $this->dao->select('o.*, c.name as customerName, c.level as level')->from(TABLE_ORDER)->alias('o')->leftJoin(TABLE_CUSTOMER)->alias('c')->on("o.customer=c.id")->where('o.deleted')->eq(0)->beginIF($userList != '')->andWhere()->markLeft(1)->where('o.assignedTo')->in($userList)->orWhere('o.createdBy')->in($userList)->orWhere('o.editedBy')->in($userList)->orWhere('o.signedBy')->in($userList)->markRight(1)->fi()->beginIF($mode == 'past')->andWhere('o.nextDate')->andWhere('o.nextDate')->lt(helper::today())->fi()->beginIF($mode == 'today')->andWhere('o.nextDate')->eq(helper::today())->fi()->beginIF($mode == 'tomorrow')->andWhere('o.nextDate')->eq(formattime(date::tomorrow(), DT_DATE1))->fi()->beginIF($mode == 'thisweek')->andWhere('o.nextDate')->between($thisWeek['begin'], $thisWeek['end'])->fi()->beginIF($mode == 'thismonth')->andWhere('o.nextDate')->between($thisMonth['begin'], $thisMonth['end'])->fi()->beginIF($mode == 'public')->andWhere('public')->eq('1')->fi()->beginIF($mode == 'assignedTo')->andWhere('o.assignedTo')->eq($this->app->user->account)->fi()->beginIF($mode == 'createdBy')->andWhere('o.createdBy')->eq($this->app->user->account)->fi()->beginIF($mode == 'signedBy')->andWhere('o.signedBy')->eq($this->app->user->account)->fi()->beginIF($mode == 'query')->andWhere($param)->fi()->beginIF($mode == 'bysearch')->andWhere($orderQuery)->fi()->andWhere('o.customer')->in($customerIdList)->orderBy($orderBy)->page($pager)->fetchAll('id');
     foreach ($orders as $order) {
         $order->products = array();
         $productList = explode(',', $order->product);
         foreach ($productList as $product) {
             if (isset($products[$product])) {
                 $order->products[] = $products[$product];
             }
         }
     }
     foreach ($orders as $order) {
         $productName = count($order->products) > 1 ? current($order->products) . $this->lang->etc : current($order->products);
         $order->title = sprintf($this->lang->order->titleLBL, $order->customerName, $productName, date('Y-m-d', strtotime($order->createdDate)));
     }
     return $orders;
 }
Exemple #8
0
 public function createAsset()
 {
     $skipFields = '';
     $skipFields .= $this->loadModel('custom')->dealWithCustomArrayField();
     $now = helper::now();
     $today = helper::today();
     $address = fixer::input('post')->get('address');
     $extendaddress = fixer::input('post')->get('extendaddress');
     $devicenumber = fixer::input('post')->get('devicenumber');
     $code = fixer::input('post')->get('code');
     $module = $this->loadModel('info')->getAllChildId(fixer::input('post')->cleanInt('module')->setDefault('module', 0)->get('module'), 'asset');
     $result1 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('address')->eq($extendaddress)->andWhere('address')->ne('IP Format Error')->andWhere('address')->ne('Conflict!')->andWhere('address')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
     $result2 = $this->dao->select('*')->from(TABLE_INFOASSET)->where('extendaddress')->eq($address)->andWhere('extendaddress')->ne('IP Format Error')->andWhere('extendaddress')->ne('Conflict!')->andWhere('extendaddress')->ne('')->beginIF($module)->andWhere('module')->in($module)->fi()->fetchAll();
     $asset = fixer::input('post')->cleanInt('module')->setDefault('module', 0)->add('createdBy', $this->app->user->account)->add('createdDate', $now)->add('lastEditedDate', $now)->add('registdate', $today)->setDefault('module', 0)->setDefault('lenddate', '0000-00-00')->setDefault('returndate', '0000-00-00')->setDefault('product', '0')->setDefault('project', '0')->setIF(!(strlen(trim($extendaddress)) == 0) && !validater::checkIP($extendaddress), 'extendaddress', 'IP Format Error')->setIF(!(strlen(trim($address)) == 0) && !validater::checkIP($address), 'address', 'IP Format Error')->removeIF(trim($address) == trim($extendaddress), 'extendaddress')->setIF($result1, 'extendaddress', 'Conflict!')->setIF($result2, 'address', 'Conflict!')->get();
     $condition = "`lib` = '{$asset->lib}' AND module = '{$asset->module}'";
     $conditionaddress = $condition . " and address != 'IP Format Error' and address != 'Conflict!'";
     $conditionextaddress = $condition . " and extendaddress != 'IP Format Error' and extendaddress != 'Conflict!'";
     $this->dao->insert(TABLE_INFOASSET)->data($asset)->autoCheck($skipFields)->batchCheck($this->config->asset->create->requiredFields, 'notempty')->check('hostname', 'unique', $condition)->checkIF(!(strlen(trim($address)) == 0), 'address', 'unique', $conditionaddress)->checkIF(!(strlen(trim($extendaddress)) == 0), 'extendaddress', 'unique', $conditionextaddress)->checkIF(!(strlen(trim($devicenumber)) == 0), 'devicenumber', 'unique', $condition)->checkIF(!(strlen(trim($code)) == 0), 'code', 'unique', $condition)->exec();
     if (!dao::isError()) {
         $assetID = $this->dao->lastInsertID();
         return $assetID;
     }
     return false;
 }
Exemple #9
0
      <th><?php 
echo $lang->task->assignedTo;
?>
</th>
      <td><?php 
echo html::select('assignedTo', $members, $task->openedBy, "class='form-control chosen'");
?>
</td><td></td>
    </tr>
    <tr>
      <th><?php 
echo $lang->task->finishedDate;
?>
</th>
      <td><div class='datepicker-wrapper'><?php 
echo html::input('finishedDate', helper::today(), "class='form-control form-date'");
?>
</div></td><td></td>
    </tr>

    <tr>
      <th><?php 
echo $lang->comment;
?>
</th>
      <td colspan='2'><?php 
echo html::textarea('comment', '', "rows='6' class='w-p98'");
?>
</td>
    </tr>
    <tr>
?>
';
</script>
<form method='post' target='hiddenwin'>
  <table class='table-1'>
    <caption><?php 
echo $sql->title;
?>
</caption>
    <tr>
      <th class='w-100px rowhead'><?php 
echo $lang->story->reviewedDate;
?>
</th>
      <td><?php 
echo html::input('reviewedDate', helper::today(), 'class=text-3');
?>
</td>
    </tr>
    <tr>
      <th class='rowhead'><?php 
echo $lang->story->reviewResult;
?>
</th>
      <td><?php 
echo html::select('result', $lang->story->reviewResultList, '', 'class=select-3 onchange="switchShow(this.value)"');
?>
</td>
    </tr>
    <tr id='rejectedReasonBox' class='hidden'>
      <th class='rowhead'><?php 
Exemple #11
0
 /**
  * Link contact.
  * 
  * @param  int    $customerID 
  * @access public
  * @return bool
  */
 public function linkContact($customerID)
 {
     $this->loadModel('action');
     $this->loadModel('contact');
     if (!$this->post->selectContact) {
         $contact = fixer::input('post')->add('customer', $customerID)->add('createdBy', $this->app->user->account)->add('createdDate', helper::now())->remove('contact')->get();
         return $this->contact->create($contact);
     }
     if ($this->post->contact) {
         $contactID = $this->post->contact;
         $contact = $this->contact->getByID($contactID);
         $contacts = $this->contact->getPairs();
         if ($contact->customer != $customerID or $contact->left != '' and strtotime($contact->left) <= strtotime(helper::today())) {
             $resume = new stdclass();
             $resume->customer = $customerID;
             $resume->contact = $contactID;
             $resumeID = $this->loadModel('resume')->create($contactID, $resume);
             if ($resumeID) {
                 $changes[] = array('field' => 'customer', 'old' => $contact->customer, 'new' => $customerID, 'diff' => '');
                 $actionID = $this->action->create('contact', $contactID, 'Edited');
                 $this->action->logHistory($actionID, $changes);
             }
             $this->loadModel('action')->create('customer', $customerID, 'linkContact', '', $this->post->newcontact ? $this->post->realname : $contacts[$this->post->contact]);
             return array('result' => 'success', 'message' => $this->lang->saveSuccess);
         }
     }
     return array('result' => 'fail', 'message' => dao::getError());
 }
Exemple #12
0
 /**
  * Paste image in kindeditor at firefox and chrome. 
  * 
  * @param  string    $data 
  * @param  string    $uid 
  * @access public
  * @return string
  */
 public function pasteImage($data, $uid)
 {
     $data = str_replace('\\"', '"', $data);
     if (!$this->checkSavePath()) {
         return false;
     }
     ini_set('pcre.backtrack_limit', strlen($data));
     preg_match_all('/<img src="(data:image\\/(\\S+);base64,(\\S+))" .+ \\/>/U', $data, $out);
     foreach ($out[3] as $key => $base64Image) {
         $imageData = base64_decode($base64Image);
         $imageSize = array('width' => 0, 'height' => 0);
         $file['extension'] = $out[2][$key];
         $file['pathname'] = $this->setPathName($key, $file['extension']);
         $file['size'] = strlen($imageData);
         $file['addedBy'] = $this->app->user->account;
         $file['addedDate'] = helper::today();
         $file['title'] = basename($file['pathname']);
         $file['editor'] = 1;
         file_put_contents($this->savePath . $file['pathname'], $imageData);
         $this->compressImage($this->savePath . $file['pathname']);
         $imageSize = $this->getImageSize($this->savePath . $file['pathname']);
         $file['width'] = $imageSize['width'];
         $file['height'] = $imageSize['height'];
         $this->dao->insert(TABLE_FILE)->data($file)->exec();
         $_SESSION['album'][$uid][] = $this->dao->lastInsertID();
         $data = str_replace($out[1][$key], $this->webPath . $file['pathname'], $data);
     }
     return $data;
 }
Exemple #13
0
 /**
  * Process attend, add dayName, comput today's status.
  * 
  * @param  object $attend 
  * @access public
  * @return object
  */
 public function processAttend($attend)
 {
     /* Compute status and remove signOut if date is today. */
     if ($attend->date == helper::today()) {
         if (time() < strtotime("{$attend->date} {$this->config->attend->signOutLimit}")) {
             $attend->signOut = '00:00:00';
         }
         $status = $this->computeStatus($attend);
         $attend->status = $status;
         if ($status == 'early') {
             $attend->status = 'normal';
         }
         if ($status == 'both') {
             $attend->status = 'late';
         }
     }
     if ($attend->status == '') {
         $attend->status = $this->computeStatus($attend);
     }
     /* Remove time. */
     if ($attend->signIn == '00:00:00') {
         $attend->signIn = '';
     }
     if ($attend->signOut == '00:00:00') {
         $attend->signOut = '';
     }
     if ($attend->manualIn == '00:00:00') {
         $attend->manualIn = '';
     }
     if ($attend->manualOut == '00:00:00') {
         $attend->manualOut = '';
     }
     $dayIndex = date('w', strtotime($attend->date));
     $attend->dayName = $this->lang->datepicker->dayNames[$dayIndex];
     return $attend;
 }
Exemple #14
0
 /**
  * Process burndown datas when the sets is smaller than the itemCounts.
  * 
  * @param  array   $sets 
  * @param  int     $itemCounts 
  * @param  date    $begin 
  * @param  date    $end 
  * @param  string  $mode 
  * @access public
  * @return array
  */
 public function processBurnData($sets, $itemCounts, $begin, $end, $mode = 'noempty')
 {
     $burnCounts = count($sets);
     $current = helper::today();
     if ($end != '0000-00-00') {
         $period = helper::diffDate($end, $begin) + 1;
         $counts = $period > $itemCounts ? $itemCounts : $period;
     } else {
         $counts = $itemCounts;
     }
     for ($i = 0; $i < $counts - $burnCounts; $i++) {
         if (helper::diffDate($current, $end) > 0) {
             break;
         }
         if (!isset($sets[$current]) and $mode != 'noempty') {
             $sets[$current]->name = $current;
             $sets[$current]->value = '';
         }
         $nextDay = date(DT_DATE1, strtotime('next day', strtotime($current)));
         $current = $nextDay;
     }
     return $sets;
 }
Exemple #15
0
 public function manageMembers($sprintID)
 {
     $sprint = $this->getSprintByID($sprintID);
     $acc = $_POST["accounts"];
     if ($acc) {
         $member = new stdclass();
         $member->role = $_POST["roles"];
         $member->account = $acc;
         $member->days = $sprint->days;
         $member->hours = $sprint->hours;
         $member->project = $sprintID;
         $member->plan = $this->getPlanIDBySprintID($sprintID);
         $member->join = helper::today();
         $member->isProject = 1;
         $this->dao->delete()->from(TABLE_TEAM)->where('project')->eq($member->project)->andWhere('account')->eq($acc)->exec();
         $this->dao->insert(TABLE_TEAM)->data($member)->exec();
     }
     $plan = $this->getPlanIDBySprintID($sprintID);
     $members = $this->dao->select('count(*)')->from(TABLE_TEAM)->where('plan')->eq($plan)->andWhere('project')->eq($sprintID)->fetchAll();
     $members = current($members[0]);
     $sqas = $this->dao->select('account')->from(TABLE_USER)->where('role')->eq('sqa')->fetchAll();
     $sqanum = count($sqas);
     for ($i = 0; $i <= $members - 1 - $sqanum; $i++) {
         $member = $this->dao->select('*')->from(TABLE_TEAM)->where('account')->eq($_POST["exsitAccounts{$i}"])->andWhere('project')->eq($sprintID)->fetch();
         $member->role = $_POST["roles{$i}"];
         $this->dao->delete()->from(TABLE_TEAM)->where('account')->eq($member->account)->andWhere('project')->eq($sprintID)->exec();
         $this->dao->insert(TABLE_TEAM)->data($member)->exec();
         $this->dao->delete()->from(TABLE_TEAM)->where('plan')->eq(0)->exec();
     }
 }
Exemple #16
0
</th>
        <th class='w-status'><?php 
echo $lang->statusAB;
?>
</th>
      </tr>
      </thead>
      <tbody>
      <?php 
foreach ($allBugs as $bug) {
    ?>
      <?php 
    if (isset($planBugs[$bug->id])) {
        continue;
    }
    if ($bug->plan and helper::diffDate($plans[$bug->plan], helper::today()) > 0) {
        continue;
    }
    ?>
      <tr>
        <td class='text-left'>
          <input class='ml-10px' type='checkbox' name='bugs[]'  value='<?php 
    echo $bug->id;
    ?>
'/> 
          <?php 
    echo html::a($this->createLink('bug', 'view', "bugID={$bug->id}"), $bug->id);
    ?>
        </td>
        <td><span class='<?php 
    echo 'pri' . zget($lang->bug->priList, $bug->pri, $bug->pri);
Exemple #17
0
 /**
  * Batch review stories.
  * 
  * @param  array   $storyIDList 
  * @access public
  * @return array
  */
 function batchReview($storyIDList, $result, $reason)
 {
     $now = helper::now();
     $date = helper::today();
     $actions = array();
     $this->loadModel('action');
     foreach ($storyIDList as $storyID) {
         $oldStory = $this->getById($storyID);
         if ($oldStory->status != 'draft' and $oldStory->status != 'changed') {
             continue;
         }
         $story = new stdClass();
         $story->reviewedDate = $date;
         $story->lastEditedBy = $this->app->user->account;
         $story->lastEditedDate = $now;
         if ($result == 'pass') {
             $story->status = 'active';
         }
         if ($reason == 'done') {
             $story->stage = 'released';
         }
         if ($result == 'reject') {
             $story->status = 'closed';
             $story->closedBy = $this->app->user->account;
             $story->closedDate = $now;
             $story->assignedTo = closed;
             $this->action->create('story', $storyID, 'Closed', '', ucfirst($reason));
         }
         $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->where('id')->eq($storyID)->exec();
         $this->setStage($storyID);
         if (strpos('done,postponed', $reason) !== false) {
             $result = 'pass';
         }
         $actions[$storyID] = $this->action->create('story', $storyID, 'Reviewed', '', ucfirst($result));
         $this->action->logHistory($actions[$storyID], array());
     }
     return $actions;
 }
Exemple #18
0
 /**
  * Process a task, judge it's status.
  * 
  * @param  object    $task 
  * @access private
  * @return object
  */
 public function processTask($task)
 {
     $today = helper::today();
     /* Delayed or not?. */
     if ($task->status !== 'done' and $task->status !== 'cancel' and $task->status != 'closed') {
         if ($task->deadline != '0000-00-00') {
             $delay = helper::diffDate($today, $task->deadline);
             if ($delay > 0) {
                 $task->delay = $delay;
             }
         }
     }
     /* Story changed or not. */
     $task->needConfirm = false;
     if ($task->storyStatus == 'active' and $task->latestStoryVersion > $task->storyVersion) {
         $task->needConfirm = true;
     }
     return $task;
 }
Exemple #19
0
 public function myburn($projectID = 0, $type = 'noweekend', $interval = 0)
 {
     $products = $this->loadModel('product')->getPairs();
     $productsAllbyheng = $this->loadModel('project')->getProducts($projectID);
     foreach ($productsAllbyheng as $productID => $productName) {
         $product_id = $productID;
         $product_name = $productName;
     }
     $this->view->position[] = html::a(helper::createLink("product", "productplan", "productID={$product_id}"), $products[$product_id]);
     $plans = $this->loadModel('productplan')->getPairs($product_id);
     $plan_id = $this->loadModel('project')->getPlanByProjectID($projectID);
     $this->view->title = $plans[$plan_id];
     $this->view->position[] = html::a(helper::createLink("pro", "index", "planID={$plan_id}"), $plans[$plan_id]);
     $projectStats = $this->loadModel('productplan')->getProjectPairs($plan_id);
     $this->view->position[] = html::select('proj', $projectStats, $projectID, "class='' onchange='byProj(this.value)'");
     $this->loadModel('report');
     // $project     = $this->commonAction(2);
     $projectInfo = $this->loadModel("project")->getByID($projectID);
     /* Get date list. */
     list($dateList, $interval) = $this->loadModel("project")->getDateList($projectInfo->begin, $projectInfo->end, $type, $interval, 'Y-m-d');
     // echo "$interval";
     $sets = $this->loadModel("project")->getBurnDataFlot($projectID);
     $limitJSON = '[]';
     $baselineJSON = '[]';
     $firstBurn = empty($sets) ? 0 : reset($sets);
     $firstTime = isset($firstBurn->value) ? $firstBurn->value : 0;
     $days = count($dateList) - 1;
     $rate = round($firstTime / $days, 2);
     $baselineJSON = '[';
     foreach ($dateList as $i => $date) {
         $baselineJSON .= ($days - $i) * $rate . ',';
     }
     $baselineJSON = rtrim($baselineJSON, ',') . ']';
     $chartData['labels'] = $this->report->convertFormat($dateList, 'j/n');
     $chartData['burnLine'] = $this->report->createSingleJSON($sets, $dateList);
     $chartData['baseLine'] = $baselineJSON;
     /* Set a space when assemble the string for english. */
     $space = $this->app->getClientLang() == 'en' ? ' ' : '';
     $dayList = array_fill(1, floor($projectInfo->days / $this->config->project->maxBurnDay) + 5, '');
     foreach ($dayList as $key => $val) {
         $dayList[$key] = $this->lang->project->interval . $space . ($key + 1) . $space . $this->lang->day;
     }
     // Update automatically
     $today = helper::today();
     $burnFromTask = $this->dao->select("sum(`left`) AS `left`")->from(TABLE_TASK)->where('project')->eq($projectID)->andWhere('deleted')->eq('0')->andWhere('status')->notin('cancel,closed')->groupBy('project')->fetch('left');
     // echo $burnFromTask;
     $burnFromBurn = $this->dao->select('*')->from(TABLE_BURN)->where('project')->eq($projectID)->andWhere('date')->eq($today)->fetch('left');
     // echo $burnFromBurn;
     $burnDiff = $burnFromTask - $burnFromBurn;
     if ($burnDiff == 0) {
         $this->view->updateJudge = 0;
     } else {
         $this->view->updateJudge = 1;
     }
     /* Assign. */
     $this->view->tabID = 'burn';
     $this->view->charts = $charts;
     $this->view->projectID = $projectID;
     $this->view->sprintID = $projectID;
     $this->view->projectName = $projectInfo->name;
     $this->view->type = $type;
     $this->view->interval = $interval;
     $this->view->chartData = $chartData;
     $this->view->dayList = array('full' => $this->lang->project->interval . $space . 1 . $space . $this->lang->day) + $dayList;
     $this->display();
 }
Exemple #20
0
 /**
  * company's todo list.
  * 
  * @param  string $type 
  * @param  string $dept 
  * @param  string $account 
  * @param  string $begin 
  * @param  string $end 
  * @access public
  * @return void
  */
 public function company($type = 'todo', $dept = '', $account = '', $begin = '', $end = '')
 {
     $this->loadModel('todo', 'oa');
     /* compute begin and end. */
     $today = helper::today();
     if ($begin == '') {
         $begin = date('Y-m-d', strtotime("{$today} -1 days"));
     }
     if ($end == '') {
         $end = date('Y-m-d', strtotime("{$begin} +7 days"));
     }
     if (strtotime($begin) > strtotime($end)) {
         $end = date('Y-m-d', strtotime("{$begin} +7 days"));
     }
     $date = array();
     $date['begin'] = date('Y-m-d', strtotime($begin));
     $date['end'] = date('Y-m-d', strtotime($end));
     /* compute account list. */
     $acountList = array();
     if ($account == '') {
         if ($dept == '') {
             $users = $this->dao->select('account, realname')->from(TABLE_USER)->where('deleted')->eq(0)->orderBy('dept')->fetchPairs();
         } else {
             $users = $this->loadModel('user')->getPairs('nodeleted,noclosed,noempty', $dept);
         }
         $accountList = array_keys($users);
     } else {
         $accountList[] = $account;
     }
     $todoList = array();
     foreach ($accountList as $user) {
         $todos = $this->todo->getList('self', $user, $date);
         $todoList[$user] = $todos;
     }
     $deptList = $this->loadModel('tree')->getPairs('', 'dept');
     $deptList[''] = $this->lang->my->company->all;
     $deptList = array_reverse($deptList, true);
     $this->view->title = $this->lang->todo->common;
     $this->view->todoList = $todoList;
     $this->view->type = $type;
     $this->view->dept = $dept;
     $this->view->account = $account;
     $this->view->begin = $date['begin'];
     $this->view->end = $date['end'];
     $this->view->deptList = $deptList;
     $this->view->users = $this->loadModel('user')->getPairs('nodeleted,noclosed');
     $this->view->userDept = $this->dao->select('account,dept')->from(TABLE_USER)->fetchPairs();
     $this->view->dateList = range(strtotime($begin), strtotime($end), 86400);
     $this->display();
 }
Exemple #21
0
 /**
  * Paste image in kindeditor at firefox and chrome. 
  * 
  * @param  string    $data 
  * @access public
  * @return string
  */
 public function pasteImage($data)
 {
     if (empty($data)) {
         return '';
     }
     $data = str_replace('\\"', '"', $data);
     $dataLength = strlen($data);
     if (ini_get('pcre.backtrack_limit') < $dataLength) {
         ini_set('pcre.backtrack_limit', $dataLength);
     }
     preg_match_all('/<img src="(data:image\\/(\\S+);base64,(\\S+))".*\\/>/U', $data, $out);
     foreach ($out[3] as $key => $base64Image) {
         $extension = strtolower($out[2][$key]);
         if (!in_array($extension, $this->config->file->imageExtensions)) {
             die;
         }
         $imageData = base64_decode($base64Image);
         $file['extension'] = $extension;
         $file['pathname'] = $this->setPathName($key, $file['extension']);
         $file['size'] = strlen($imageData);
         $file['addedBy'] = $this->app->user->account;
         $file['addedDate'] = helper::today();
         $file['title'] = basename($file['pathname']);
         file_put_contents($this->savePath . $file['pathname'], $imageData);
         $this->dao->insert(TABLE_FILE)->data($file)->exec();
         $data = str_replace($out[1][$key], $this->webPath . $file['pathname'], $data);
     }
     return $data;
 }
Exemple #22
0
 /**
  * Get unread notice for user.
  * 
  * @param  string $account 
  * @param  string $skipNotice 
  * @access public
  * @return array
  */
 public function getUnreadNotice($account = '', $skipNotice = '')
 {
     if ($account == '') {
         $account = $this->app->user->account;
     }
     $users = $this->loadModel('user')->getPairs();
     $actions = $this->dao->select('*')->from(TABLE_ACTION)->where('`read`')->eq('0')->andWhere('reader')->like("%,{$account},%")->beginIf($skipNotice != '')->andWhere('id')->notin($skipNotice)->fi()->orderBy('id_desc')->fetchAll('id');
     $histories = $this->getHistory(array_keys($actions));
     foreach ($actions as $actionID => $action) {
         $action->history = isset($histories[$actionID]) ? $histories[$actionID] : array();
     }
     if (!empty($actions)) {
         $actions = $this->transformActions($actions);
     }
     /* Create action notices. */
     $notices = array();
     foreach ($actions as $action) {
         $notice = new stdclass();
         $notice->id = $action->id;
         $notice->title = sprintf($this->lang->action->noticeTitle, $action->objectLabel, $action->objectLink, $action->appName, $action->objectName);
         $notice->type = 'success';
         $notice->read = helper::createLink('action', 'read', "actionID={$notice->id}");
         /* process user and status. */
         if ($action->objectType == 'leave') {
             $this->loadModel('leave', 'oa');
         }
         if ($action->objectType == 'attend') {
             $this->loadModel('attend', 'oa');
         }
         if ($action->objectType == 'refund') {
             $this->loadModel('refund', 'oa');
         }
         if (isset($users[$action->actor])) {
             $action->actor = $users[$action->actor];
         }
         if ($action->action == 'assigned' and isset($users[$action->extra])) {
             $action->extra = $users[$action->extra];
         }
         if ($action->action == 'reviewed' and isset($this->lang->{$action->objectType}->statusList[$action->extra])) {
             $action->extra = $this->lang->{$action->objectType}->statusList[$action->extra];
         }
         if ($action->action == 'reviewed' and isset($this->lang->{$action->objectType}->reviewStatusList[$action->extra])) {
             $action->extra = $this->lang->{$action->objectType}->reviewStatusList[$action->extra];
         }
         /* Get contents. */
         ob_start();
         $this->printAction($action);
         $notice->content = ob_get_contents();
         ob_end_clean();
         $notices[$action->id] = $notice;
     }
     /* Create todo notices. */
     $date = helper::today();
     $now = helper::now();
     $link = helper::createLink('sys.todo', 'calendar');
     $todos = $this->loadModel('todo', 'sys')->getList('self', $account, $date, 'undone');
     $interval = $this->config->pingInterval;
     $begin[1] = date('Hi', strtotime($now));
     $end[1] = date('Hi', strtotime("+{$interval} seconds {$now}"));
     $begin[10] = date('Hi', strtotime("+10 minute {$now}"));
     $end[10] = date('Hi', strtotime("+10 minute {$interval} seconds {$now}"));
     $begin[30] = date('Hi', strtotime("+30 minute {$now}"));
     $end[30] = date('Hi', strtotime("+30 minute {$interval} seconds {$now}"));
     foreach ($todos as $todo) {
         if (empty($todo->begin)) {
             continue;
         }
         $time = str_replace(':', '', $todo->begin);
         $lastTime = 0;
         if ((int) $time > (int) $begin[1] and (int) $time <= (int) $end[1]) {
             $lastTime = 1;
         }
         if ((int) $time > (int) $begin[10] and (int) $time <= (int) $end[10]) {
             $lastTime = 10;
         }
         if ((int) $time > (int) $begin[30] and (int) $time <= (int) $end[30]) {
             $lastTime = 30;
         }
         if ($lastTime) {
             $notice = new stdclass();
             $notice->id = 'todo' . $todo->id;
             $notice->title = sprintf($this->lang->action->noticeTitle, $this->lang->todo->common, $link, 'oa', "{$todo->begin} {$todo->name}");
             $notice->content = '';
             $notice->type = 'success';
             $notice->read = '';
             $notices[$notice->id] = $notice;
         }
     }
     /* Create past order notice. */
     $orders = $this->loadModel('order', 'crm')->getList('past');
     foreach ($orders as $order) {
         /* Skip not assigned to me, read and showed notice. */
         if ($order->assignedTo != $account) {
             continue;
         }
         if (isset($this->app->user->readNotices["order{$order->id}"])) {
             continue;
         }
         if (strpos(",{$skipNotice},", ",order{$order->id},") !== false) {
             continue;
         }
         $link = helper::createLink('crm.order', 'view', "orderID={$order->id}");
         $notice = new stdclass();
         $notice->id = 'order' . $order->id;
         $notice->title = sprintf($this->lang->action->noticeTitle, $this->lang->order->record . $this->lang->order->common, $link, 'crm', $order->title);
         $notice->content = '';
         $notice->type = 'success';
         $notice->read = helper::createLink('action', 'read', "actionID={$notice->id}&type=order");
         $notices[$notice->id] = $notice;
     }
     return $notices;
 }
Exemple #23
0
 /**
  * Review a story.
  * 
  * @param  int    $storyID 
  * @access public
  * @return bool
  */
 public function review($storyID)
 {
     if ($this->post->result == false) {
         die(js::alert($this->lang->story->mustChooseResult));
     }
     if ($this->post->result == 'revert' and $this->post->preVersion == false) {
         die(js::alert($this->lang->story->mustChoosePreVersion));
     }
     $oldStory = $this->dao->findById($storyID)->from(TABLE_STORY)->fetch();
     $now = helper::now();
     $date = helper::today();
     $story = fixer::input('post')->remove('result,preVersion,comment')->setDefault('reviewedDate', $date)->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->setIF($this->post->result == 'pass' and $oldStory->status == 'draft', 'status', 'active')->setIF($this->post->result == 'pass' and $oldStory->status == 'changed', 'status', 'active')->setIF($this->post->result == 'reject', 'closedBy', $this->app->user->account)->setIF($this->post->result == 'reject', 'closedDate', $now)->setIF($this->post->result == 'reject', 'assignedTo', 'closed')->setIF($this->post->result == 'reject', 'status', 'closed')->setIF($this->post->result == 'revert', 'version', $this->post->preVersion)->setIF($this->post->result == 'revert', 'status', 'active')->setIF($this->post->closedReason == 'done', 'stage', 'released')->removeIF($this->post->result != 'reject', 'closedReason, duplicateStory, childStories')->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'duplicate', 'duplicateStory')->removeIF($this->post->result == 'reject' and $this->post->closedReason != 'subdivided', 'childStories')->get();
     $this->dao->update(TABLE_STORY)->data($story)->autoCheck()->batchCheck($this->config->story->review->requiredFields, 'notempty')->checkIF($this->post->result == 'reject', 'closedReason', 'notempty')->checkIF($this->post->result == 'reject' and $this->post->closedReason == 'duplicate', 'duplicateStory', 'notempty')->checkIF($this->post->result == 'reject' and $this->post->closedReason == 'subdivided', 'childStories', 'notempty')->where('id')->eq($storyID)->exec();
     if ($this->post->result == 'revert') {
         $preTitle = $this->dao->select('title')->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWHere('version')->eq($this->post->preVersion)->fetch('title');
         $this->dao->update(TABLE_STORY)->set('title')->eq($preTitle)->where('id')->eq($storyID)->exec();
         $this->dao->delete()->from(TABLE_STORYSPEC)->where('story')->eq($storyID)->andWHere('version')->eq($oldStory->version)->exec();
         $this->dao->delete()->from(TABLE_FILE)->where('objectType')->eq('story')->andWhere('objectID')->eq($storyID)->andWhere('extra')->eq($oldStory->version)->exec();
     }
     $this->setStage($storyID);
     return true;
 }
 /**
  * Review a story.
  * 
  * @param  int    $sqlID
  * @access public
  * @return bool
  */
 public function review($sqlID)
 {
     if ($this->post->result == false) {
         die(js::alert($this->lang->story->mustChooseResult));
     }
     if ($this->post->result == 'revert' and $this->post->preVersion == false) {
         die(js::alert($this->lang->story->mustChoosePreVersion));
     }
     $oldSql = $this->dao->findById($sqlID)->from(TABLE_SQLREVIEW)->fetch();
     $now = helper::now();
     $date = helper::today();
     $sql = fixer::input('post')->remove('result,preVersion,comment')->setDefault('reviewedDate', $date)->add('lastEditedBy', $this->app->user->account)->add('lastEditedDate', $now)->setIF($this->post->result == 'pass' and $oldSql->status == 'draft', 'status', 'active')->setIF($this->post->result == 'pass' and $oldSql->status == 'changed', 'status', 'active')->setIF($this->post->result == 'pass' and $oldSql->stage == 'wait', 'stage', 'passed')->setIF($this->post->result == 'reject', 'closedBy', $this->app->user->account)->setIF($this->post->result == 'reject', 'closedDate', $now)->setIF($this->post->result == 'reject', 'assignedTo', 'closed')->setIF($this->post->result == 'reject', 'status', 'closed')->setIF($this->post->result == 'revert', 'version', $this->post->preVersion)->setIF($this->post->result == 'revert', 'status', 'active')->setIF($this->post->closedReason == 'done', 'stage', 'released')->get();
     $this->dao->update(TABLE_SQLREVIEW)->data($sql)->autoCheck()->batchCheck($this->config->story->review->requiredFields, 'notempty')->checkIF($this->post->result == 'reject', 'closedReason', 'notempty')->where('id')->eq($sqlID)->exec();
     $this->setStage($sqlID);
     return true;
 }
Exemple #25
0
 /**
  * Paste image in kindeditor at firefox and chrome. 
  * 
  * @param  string    $data 
  * @access public
  * @return string
  */
 public function pasteImage($data)
 {
     $data = str_replace('\\"', '"', $data);
     ini_set('pcre.backtrack_limit', strlen($data));
     preg_match_all('/<img src="(data:image\\/(\\S+);base64,(\\S+))".*\\/>/U', $data, $out);
     foreach ($out[3] as $key => $base64Image) {
         $imageData = base64_decode($base64Image);
         $file['extension'] = $out[2][$key];
         $file['pathname'] = $this->setPathName($key, $file['extension']);
         $file['size'] = strlen($imageData);
         $file['addedBy'] = $this->app->user->account;
         $file['addedDate'] = helper::today();
         $file['title'] = basename($file['pathname']);
         file_put_contents($this->savePath . $file['pathname'], $imageData);
         $this->dao->insert(TABLE_FILE)->data($file)->exec();
         $data = str_replace($out[1][$key], $this->webPath . $file['pathname'], $data);
     }
     return $data;
 }
Exemple #26
0
?>
 <?php 
echo html::icon($lang->icons['start']);
?>
</small>
  </div>
</div>
<form class='form-condensed' method='post' target='hiddenwin' onsubmit='return checkLeft();'>
  <table class='table table-form'>
    <tr>
      <th class='w-80px'><?php 
echo $lang->task->realStarted;
?>
</th>
      <td class='w-p25-f'><div class='datepicker-wrapper datepicker-date'><?php 
echo html::input('realStarted', helper::today(), "class='form-control form-date'");
?>
</div></td><td></td>
    </tr>  
    <tr>
      <th><?php 
echo $lang->task->consumed;
?>
</th>
      <td><div class='input-group'><?php 
echo html::input('consumed', $task->consumed, "class='form-control'");
?>
 <span class='input-group-addon'><?php 
echo $lang->task->hour;
?>
</span></div></td><td></td>
Exemple #27
0
<div id='featurebar'>
  <div class='f-left'>
  <?php 
if (!isset($type)) {
    $type = 'today';
}
if (!isset($period)) {
    $period = 'today';
}
$date = isset($date) ? $date : helper::today();
echo $userList . $lang->arrow;
echo "<span id='todoTab'>";
common::printLink('user', 'todo', "account={$account}", $lang->user->todo);
echo '</span>';
echo "<span id='taskTab'>";
common::printLink('user', 'task', "account={$account}", $lang->user->task);
echo '</span>';
echo "<span id='bugTab'>";
common::printLink('user', 'bug', "account={$account}", $lang->user->bug);
echo '</span>';
echo "<span id='dynamicTab'>";
common::printLink('user', 'dynamic', "type=today&account={$account}", $lang->user->dynamic);
echo '</span>';
echo "<span id='projectTab'>";
common::printLink('user', 'project', "account={$account}", $lang->user->project);
echo '</span>';
echo "<span id='profileTab'>";
common::printLink('user', 'profile', "account={$account}", $lang->user->profile);
echo '</span>';
$activedSpan = $this->app->getMethodName() . 'Tab';
echo "<script>\$('#{$activedSpan}').addClass('active')</script>";
      <td><?php 
    echo html::input('left[1]', '');
    ?>
</td>
    </tr>
    <tr>
      <td class='w-70px'><?php 
    echo $lang->comment;
    ?>
</td>
      <td><?php 
    echo html::textarea('comment', '', "data-mini='true'");
    ?>
</td>
    </tr>
    <tr class="a-center">
      <td colspan="2">
      <?php 
    echo html::submitButton('', 'data-inline="true" data-theme="b"');
    echo html::linkButton($lang->goback, $this->createLink('task', 'view', "taskID={$task->id}"), 'self', "data-inline='true'");
    echo html::hidden('dates[1]', helper::today()) . html::hidden("id[1]", 1);
    ?>
     </td>
    </tr>
    <?php 
}
?>
  <table>
</form>
<?php 
include '../../common/view/m.footer.html.php';
 public function batchCreatePlan($date = 'today', $account = '')
 {
     if ($date == 'today') {
         $this->view->date = helper::today();
     }
     if (!empty($_POST)) {
         $this->todo->batchCreate();
         if (dao::isError()) {
             die(js::error(dao::getError()));
         }
         /* Locate the browser. */
         die(js::locate($this->createLink('my', 'plan', "date={$this->post->date}"), 'parent'));
     }
     $header['title'] = $this->lang->my->common . $this->lang->colon . $this->lang->todo->create;
     $position[] = $this->lang->todo->create;
     $this->view->header = $header;
     $this->view->position = $position;
     $this->view->times = $this->todo->buildTimeList($this->config->todo->times->begin, $this->config->todo->times->end, $this->config->todo->times->delta);
     $this->view->time = $this->todo->now();
     $this->display();
 }
Exemple #30
0
include '../../common/view/m.header.html.php';
?>
</div>
<h3><?php 
echo $lang->story->review . $lang->colon . $story->title;
?>
</h3>
<form class='form-condensed' method='post' target='hiddenwin'>
  <table class='table table-form'>
    <tr>
      <td class='w-70px'><?php 
echo $lang->story->reviewedDate;
?>
</td>
      <td><?php 
echo html::input('reviewedDate', helper::today());
?>
</td>
    </tr>
    <tr>
      <td><?php 
echo $lang->story->reviewResult;
?>
</td>
      <td><?php 
echo html::select('result', $lang->story->reviewResultList, '', 'onchange="switchShow(this.value)"');
?>
</td>
    </tr>
    <tr id='rejectedReasonBox' class='hide'>
      <td><?php