Ejemplo n.º 1
0
 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $task = null;
         if (isset($param->CallbackParameter->id) && !($task = Task::get(trim($param->CallbackParameter->id))) instanceof Task) {
             throw new Exception('Invalid Task passed in!');
         }
         if (!isset($param->CallbackParameter->instructions) || ($instructions = trim($param->CallbackParameter->instructions)) === '') {
             throw new Exception('Instructions are required!');
         }
         if (!isset($param->CallbackParameter->customerId) || !($customer = Customer::get(trim($param->CallbackParameter->customerId))) instanceof Customer) {
             throw new Exception('Invalid Customer Passed in!');
         }
         $tech = isset($param->CallbackParameter->techId) ? UserAccount::get(trim($param->CallbackParameter->techId)) : null;
         $order = isset($param->CallbackParameter->orderId) ? Order::get(trim($param->CallbackParameter->orderId)) : null;
         $dueDate = new UDate(trim($param->CallbackParameter->dueDate));
         $status = isset($param->CallbackParameter->statusId) ? TaskStatus::get(trim($param->CallbackParameter->statusId)) : null;
         if (!$task instanceof Task) {
             $task = Task::create($customer, $dueDate, $instructions, $tech, $order);
         } else {
             $task->setCustomer($customer)->setDueDate($dueDate)->setInstructions($instructions)->setTechnician($tech)->setFromEntityId($order instanceof Order ? $order->getId() : '')->setFromEntityName($order instanceof Order ? get_class($order) : '')->setStatus($status)->save();
         }
         // 			$results['url'] = '/task/' . $task->getId() . '.html?' . $_SERVER['QUERY_STRING'];
         $results['item'] = $task->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Ejemplo n.º 2
0
 public static function getAllOutstandingCount($user_id)
 {
     $count = 0;
     foreach (TaskList::get($where = array('user_id' => $user_id)) as $tasklist) {
         $count += count(Task::get($where = array('list_id' => $tasklist->getId(), 'complete' => '0')));
     }
     return $count;
 }
Ejemplo n.º 3
0
 function __toString()
 {
     try {
         $this->task->get();
     } catch (Exception $e) {
     }
     return "id => " . $this->id . "<br>" . "start =>" . date("Y/m/d H:i:s", $this->start) . "<br>" . "end =>" . date("Y/m/d H:i:s", $this->end) . "<br>" . "value => " . $this->value . "<br>" . $this->task . "achieveTime => " . $this->achieveTime . "<br>";
 }
Ejemplo n.º 4
0
 public function addWorkForm()
 {
     $project = Task::get()->map('ID', 'Title');
     DateField::set_default_config('showcalendar', true);
     DateField::set_default_config('dateformat', 'dd/MM/YYYY');
     $fields = new FieldList(new DropDownField('TaskID', 'Project', $project), new TextField('Title'), new DropDownField("Status", "Status", singleton('Task')->dbObject('Status')->enumValues()), new DateField('Date', 'Date'), new NumericField('HourSpent', 'Time Spent in Hours'));
     $actions = new FieldList(new FormAction('doworkadd', 'Submit'));
     return new Form($this, 'addWorkForm', $fields, $actions);
 }
Ejemplo n.º 5
0
 public function __toString()
 {
     try {
         $this->task->get();
         $this->user->get();
     } catch (Exception $e) {
         return "";
     }
     return 'id = ' . $this->id . "<br>" . '$this->start = ' . $this->start . "<br>" . '$this->end = ' . $this->end . "<br>" . '$this->desc = ' . $this->description . "<br>" . '$this->state = ' . $this->state . "<br>" . '$this->feedback = ' . $this->feedback . "<br>" . $this->task . $this->user;
 }
Ejemplo n.º 6
0
 public function add()
 {
     $this->load->library('jdf');
     $this->load->helper('form');
     $this->load->library('form_validation');
     $this->load->library("session");
     if ($this->form_validation->run('item/add') === FALSE) {
         $this->load->view("templates/errorForm.php", array("fields" => array('rating', 'isDone', 'task', 'date', 'endTime', 'startTime')));
     } else {
         $item = new Item();
         $task = new Task();
         $user = new User($this->session->getStudentId());
         if ($this->input->post("isDone") == 1) {
             $state = ITEM_STATE_DONE;
         } else {
             $state = ITEM_STATE_UNDONE;
         }
         $task->where("user_id", $this->session->getStudentId());
         $task->where("id", $this->input->post("task"));
         $start = makeTime($this->input->post("date"), $this->input->post("startTime"));
         $end = makeTime($this->input->post("date"), $this->input->post("endTime"));
         try {
             $task->get();
             $item->create($start, $end, $this->input->post("description"), $state, $this->input->post("rating"))->save($user, $task);
             $this->load->view("item/item_created.php", array("item" => $this->setFormat(array($item))));
         } catch (Item_Overlap_With_Other_Item $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Overlap_With_Other_Item();
         } catch (Item_Create_With_Zero_Duration $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Create_With_Zero_Duration();
         } catch (Item_Feedback_Wrong $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Feedback_Wrong();
         } catch (Item_Start_Greater_Than_End_Exception $e) {
             $this->load->view("item/item_error.php");
             Item_Error::Item_Start_Greater_Than_End_Exception();
         } catch (Task_Not_Found $e) {
             $this->load->view("task/task_error.php");
         }
     }
 }
Ejemplo n.º 7
0
					</div>
					
					<input type="hidden" name="id" value="<?php 
    echo $tasklist->getId();
    ?>
">
	        	</form>
	        	
        	</li>
        	
        	<?php 
    $cond_task = array('list_id' => $tasklist->getId());
    if (!isset($_GET['show_complete'])) {
        $cond_task['complete'] = '0';
    }
    foreach (Task::get($where = $cond_task, $order = "`pinned` DESC, `complete` ASC") as $task) {
        ?>
		        
		        <!--<li class="list-group-item" id="task-<?php 
        echo $task->getId();
        ?>
">-->
		        <li class="list-group-item" <?php 
        if ($task->getComplete() == 1) {
            ?>
style="text-decoration:line-through"<?php 
        }
        ?>
 id="task-<?php 
        echo $task->getId();
        ?>
 public function hasActiveTaskCheckedIn($taskid)
 {
     $Task = new Task($taskid);
     return strtotime($Task->get('checkInTime')) - strtotime($Task->get('createdTime')) > 2;
 }
Ejemplo n.º 9
0
<?php

/**
 * 发微博
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::RequireLogin();
$task = new Task();
$id = intval($_GET['id']);
$TEMPLATE['data'] = $data = $task->get($id);
if ($data['uid'] != Passport::GetLoginUid()) {
    echo '没有权限!';
    exit;
}
switch ($_POST['action']) {
    case '修改':
        $TEMPLATE['data'] = array_merge($data, $_POST);
        if (!validate()) {
        } else {
            $tableInfo = array('title' => $_POST['title'], 'content' => $_POST['content']);
            if ($data['cat'] == 'weibo') {
                if ($_FILES['image']['tmp_name']) {
                    @mkdir(UPLOAD_PATH, 0777, true);
                    $save_file = $upload_file = UPLOAD_PATH . microtime(true) . '_' . Pinyin::get($_FILES['image']['name']);
                    move_uploaded_file($_FILES['image']['tmp_name'], $save_file);
                    $tableInfo['pic'] = $save_file;
                }
            }
            if ($_POST['time'] == 'on') {
 /**
  * Display a listing of the resource.
  * GET /tasks
  *
  * @return Response
  */
 public function index()
 {
     return Task::get();
 }
Ejemplo n.º 11
0
 /**
  * Getting the items
  *
  * @param unknown $sender
  * @param unknown $param
  * @throws Exception
  *
  */
 public function actionTask($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         if (!isset($param->CallbackParameter->taskId) || !($task = Task::get(trim($param->CallbackParameter->taskId))) instanceof Task) {
             throw new Exception('Invalid Task provided!');
         }
         if (!isset($param->CallbackParameter->method) || ($method = trim(trim($param->CallbackParameter->method))) === '' || !method_exists($task, $method)) {
             throw new Exception('Invalid Action Method!');
         }
         $comments = isset($param->CallbackParameter->comments) ? trim($param->CallbackParameter->comments) : '';
         $results['item'] = $task->{$method}(Core::getUser(), $comments)->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage();
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
Ejemplo n.º 12
0
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::RequireLogin();
$user = new User();
$data = $user->get(Passport::GetLoginUid());
$last_exec = $data['last_exec'];
if (time() - $last_exec > 60 * 60) {
    $TEMPLATE['last_exec'] = max($last_exec, 1);
}
$task = new Task();
switch ($_GET['action']) {
    case 'send':
        $thirdAccount = new ThirdAccount();
        $id = intval($_GET['id']);
        $item = $task->get($id);
        if ($item) {
            $type = $item['type'];
            $arr = explode('|', $type);
            $third = $thirdAccount->getByType($arr[0], $arr[1], $item['uid']);
            $api = Factory::CreateAPI2($arr[0], $arr[1], $third);
            if ($item['cat'] == 'weibo') {
                $ret = $api->upload($item['content'], $item['pic']);
            } else {
                $ret = $api->publish($item['title'], $item['content']);
            }
            $TEMPLATE['report'] = array();
            $TEMPLATE['report'][$type] = array('id' => $id, 'status' => $ret === true, 'msg' => $ret === true ? '发送成功!<a href="' . $third['url'] . '" target="_blank">查看</a>' : '发送失败:' . $ret);
            $task->UpdateStatus($ret === true ? Task::OK : Task::ERROR, $id, $ret, time());
        }
        break;
Ejemplo n.º 13
0
<?php

/**
 * 详细信息
 * @author 潘洪学 panliu888@gmail.com
 * @create_date	2011-10
 */
include_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'init.php';
Passport::RequireLogin();
$task = new Task();
$id = intval($_GET['id']);
$TEMPLATE['data'] = $task->get($id);
$TEMPLATE['data']['pic'] = get_pic($TEMPLATE['data']['pic']);
/**
* 	const OK	= 100;	// 发送成功
	const DELETE_OK		= -10;	// 取消的
	const DELETE_ERR	= -20;
	const DELETE_TASK	= -30;
	const ERROR	= -1;	// 发送失败
	const TASK	= 0;	// 定时任务
	const EXECING= 1;	// 正在执行任务
	const TASK_EDIT = 2; // 修改中
*/
switch ($TEMPLATE['data']['status']) {
    case Task::OK:
        $TEMPLATE['data']['status_text'] = '发送成功';
        break;
    case Task::DELETE_OK:
        $TEMPLATE['data']['status_text'] = '从发送成功列表删除';
        break;
    case Task::DELETE_ERR:
 public function cancel_task()
 {
     // Find
     $Task = new Task($this->REQUEST['id']);
     // Hook
     $this->HookManager->processEvent('TASK_CANCEL', array('Task' => &$Task));
     // Force
     try {
         // Cencel task - will throw Exception on error
         $Task->cancel();
         // Success
         $result['success'] = true;
         if ($Task->get('typeID') == 12 || $Task->get('typeID') == 13) {
             $Host = new Host($Task->get('hostID'));
             $SnapinJob = $Host->getActiveSnapinJob();
             $SnapinTasks = $this->getClass('SnapinTaskManager')->find(array('jobID' => $SnapinJob->get('id')));
             print $SnapinJob->get('id');
             foreach ((array) $SnapinTasks as $SnapinTask) {
                 $SnapinTask->destroy();
             }
             $SnapinJob->destroy();
         }
         if ($Task->get('typeID') == 8) {
             $MSA = current($this->getClass('MulticastSessionsAssociationManager')->find(array('taskID' => $Task->get('id'))));
             if ($MSA && $MSA->isValid()) {
                 $MS = new MulticastSessions($MSA->get('msID'));
                 $MS->set('clients', $MS->get('clients') - 1)->save();
                 if ($MS->get('clients') <= 0) {
                     $MS->set('completetime', $this->formatTime('now', 'Y-m-d H:i:s'))->set('stateID', 5)->save();
                 }
             }
         }
         $Task->cancel();
     } catch (Exception $e) {
         // Failure
         $result['error'] = $e->getMessage();
     }
     // Output
     if ($this->isAJAXRequest()) {
         print json_encode($result);
     } else {
         if ($result['error']) {
             $this->fatalError($result['error']);
         } else {
             $this->FOGCore->redirect(sprintf('?node=%s', $this->node));
         }
     }
 }
Ejemplo n.º 15
0
 function get_tasks($filter = null)
 {
     $additional_criteria = '';
     if (isset($filter)) {
         if ($filter == 'incomplete') {
             $additional_criteria = 'AND is_complete = 0';
         } else {
             if ($filter == 'complete') {
                 $additional_criteria = 'AND is_complete = 1';
             }
         }
     }
     $task = new Task();
     $tasks = $task->get(" WHERE project_id = {$this->id} {$additional_criteria}", array('order', 'ASC'));
     return $tasks;
 }
 public function updateStats()
 {
     foreach ($this->getClass('MulticastSessionsAssociationManager')->find(array('msid' => $this->intID)) as $MultiSessAssoc) {
         $Task = new Task($MultiSessAssoc->get('taskID'));
         if ($Task && $Task->isValid()) {
             $TaskPercent[] = $Task->get('percent');
         }
     }
     $TaskPercent = array_unique((array) $TaskPercent);
     $MultiSess = new MulticastSessions($this->intID);
     $MultiSess->set('percent', max((array) $TaskPercent))->save();
 }
Ejemplo n.º 17
0
 public function Tasks()
 {
     $tasks = Task::get();
     return $tasks;
 }
Ejemplo n.º 18
0
 /**
  * (non-PHPdoc)
  * @see DetailsPageAbstract::saveItem()
  */
 public function saveItem($sender, $param)
 {
     $results = $errors = array();
     try {
         Dao::beginTransaction();
         $kit = !isset($param->CallbackParameter->id) ? new Kit() : Kit::get(trim($param->CallbackParameter->id));
         if (!$kit instanceof Kit) {
             throw new Exception('Invalid Kit passed in!');
         }
         if (!isset($param->CallbackParameter->productId) || !($product = Product::get(trim($param->CallbackParameter->productId))) instanceof Product) {
             throw new Exception('Invalid Kit Product passed in!');
         }
         if (!isset($param->CallbackParameter->items) || count($items = $param->CallbackParameter->items) === 0) {
             throw new Exception('No Kit Components passed in!');
         }
         $task = null;
         if (isset($param->CallbackParameter->taskId) && !($task = Task::get(trim($param->CallbackParameter->taskId))) instanceof Task) {
             throw new Exception('Invalid Task passed in!');
         }
         $underCostReason = '';
         if (isset($param->CallbackParameter->underCostReason) && ($underCostReason = trim($param->CallbackParameter->underCostReason)) === '') {
             throw new Exception('UnderCostReason is Required!');
         }
         $isNewKit = false;
         if (trim($kit->getId()) === '') {
             $kit = Kit::create($product, $task);
             $isNewKit = true;
         } else {
             $kit->setTask($task)->save();
         }
         //add all the components
         foreach ($items as $item) {
             if (!($componentProduct = Product::get(trim($item->productId))) instanceof Product) {
                 continue;
             }
             if (($componentId = trim($item->id)) === '' && intval($item->active) === 1) {
                 $kit->addComponent($componentProduct, intval($item->qty));
             } else {
                 if (($kitComponent = KitComponent::get($componentId)) instanceof KitComponent) {
                     if ($kitComponent->getKit()->getId() !== $kit->getId()) {
                         continue;
                     }
                     if (intval($item->active) === 0) {
                         //deactivation
                         $kitComponent->setActive(false)->save();
                     } else {
                         $kitComponent->setQty(intval($item->qty))->save();
                     }
                 }
             }
         }
         if (trim($underCostReason) !== '') {
             $kit->addComment('The reason for continuing bulding this kit, when its cost is greater than its unit price: ' . $underCostReason, Comments::TYPE_WORKSHOP);
         }
         if ($isNewKit === true) {
             $kit->finishedAddingComponents();
         }
         $results['url'] = '/kit/' . $kit->getId() . '.html' . (trim($_SERVER['QUERY_STRING']) === '' ? '' : '?' . $_SERVER['QUERY_STRING']);
         if ($isNewKit === true) {
             $results['printUrl'] = '/print/kit/' . $kit->getId() . '.html?printlater=1';
         }
         $results['createdFromNew'] = $isNewKit;
         $results['item'] = $kit->getJson();
         Dao::commitTransaction();
     } catch (Exception $ex) {
         Dao::rollbackTransaction();
         $errors[] = $ex->getMessage() . '<pre>' . $ex->getTraceAsString() . '</pre>';
     }
     $param->ResponseData = StringUtilsAbstract::getJson($results, $errors);
 }
 private function serviceLoop()
 {
     while (true) {
         try {
             $StorageNode = current($this->getClass('StorageNodeManager')->find(array('isMaster' => 1, 'isEnabled' => 1, 'ip' => $this->FOGCore->getIPAddress())));
             if (!$StorageNode || !$StorageNode->isValid()) {
                 throw new Exception(sprintf(" | This is not the master node"));
             }
             $myroot = $StorageNode->get('path');
             $allTasks = MulticastTask::getAllMulticastTasks($myroot);
             $this->FOGCore->out(sprintf(" | %s task(s) found", count($allTasks)), $this->dev);
             $RMTasks = $this->getMCTasksNotInDB($KnownTasks, $allTasks);
             $jobcancelled = false;
             if (count($RMTasks)) {
                 $this->outall(sprintf(" | Cleaning %s task(s) removed from FOG Database.", count($RMTasks)));
                 foreach ((array) $RMTasks as $RMTask) {
                     $this->outall(sprintf(" | Cleaning Task (%s) %s", $RMTask->getID(), $RMTask->getName()));
                     $Assocs = $this->getClass('MulticastSessionsAssociationManager')->find(array('msID' => $RMTask->getID()));
                     $curSession = new MulticastSessions($RMTask->getID());
                     foreach ($Assocs as $Assoc) {
                         if ($Assoc && $Assoc->isValid()) {
                             if ($this->getClass('Task', $Assoc->get('taskID'))->get('stateID') == 5) {
                                 $jobcancelled = true;
                             }
                         }
                     }
                     if ($jobcancelled || $this->getClass('MulticastSessions', $RMTask->getID())->get('stateID') == 5) {
                         $RMTask->killTask();
                         $KnownTasks = $this->removeFromKnownList($KnownTasks, $RMTask->getID());
                         $this->outall(sprintf(" | Task (%s) %s has been cleaned as cancelled.", $RMTask->getID(), $RMTask->getName()));
                         $this->getClass('MulticastSessionsAssociationManager')->destroy(array('msID' => $RMTask->getID()));
                     } else {
                         $KnownTasks = $this->removeFromKnownList($KnownTasks, $RMTask->getID());
                         $this->outall(sprintf(" | Task (%s) %s has been cleaned as complete.", $RMTask->getID(), $RMTask->getName()));
                         $this->getClass('MulticastSessionsAssociationManager')->destroy(array('msID' => $RMTask->getID()));
                     }
                 }
             } else {
                 if (!$allTasks) {
                     throw new Exception(' * No Tasks Found!');
                 }
             }
             foreach ((array) $allTasks as $curTask) {
                 if ($this->isMCTaskNew($KnownTasks, $curTask->getID())) {
                     $this->outall(sprintf(" | Task (%s) %s is new!", $curTask->getID(), $curTask->getName()));
                     if (file_exists($curTask->getImagePath())) {
                         $this->outall(sprintf(" | Task (%s) %s image file found.", $curTask->getID(), $curTask->getImagePath()));
                         if ($curTask->getClientCount() > 0) {
                             $this->outall(sprintf(" | Task (%s) %s client(s) found.", $curTask->getID(), $curTask->getClientCount()));
                             if (is_numeric($curTask->getPortBase()) && $curTask->getPortBase() % 2 == 0) {
                                 $this->outall(sprintf(" | Task (%s) %s sending on base port: %s", $curTask->getID(), $curTask->getName(), $curTask->getPortBase()));
                                 $this->outall(sprintf("CMD: %s", $curTask->getCMD()));
                                 if ($curTask->startTask()) {
                                     $this->outall(sprintf(" | Task (%s) %s has started.", $curTask->getID(), $curTask->getName()));
                                     $KnownTasks[] = $curTask;
                                 } else {
                                     $this->outall(sprintf(" | Task (%s) %s failed to start!", $curTask->getID(), $curTask->getName()));
                                     $this->outall(sprintf(" | * Don't panic, check all your settings!"));
                                     $this->outall(sprintf(" |       even if the interface is incorrect the task won't start."));
                                     $this->outall(sprintf(" |       If all else fails run the following command and see what it says:"));
                                     $this->outall(sprintf(" |  %s", $curTask->getCMD()));
                                     if ($curTask->killTask()) {
                                         $this->outall(sprintf(" | Task (%s) %s has been cleaned.", $curTask->getID(), $curTask->getName()));
                                     } else {
                                         $this->outall(sprintf(" | Task (%s) %s has NOT been cleaned.", $curTask->getID(), $curTask->getName()));
                                     }
                                 }
                             } else {
                                 $this->outall(sprintf(" | Task (%s) %s failed to execute, port must be even and numeric.", $curTask->getID(), $curTask->getName()));
                             }
                         } else {
                             $this->outall(sprintf(" | Task (%s) %s failed to execute, no clients are included!", $curTask->getID(), $curTask->getName()));
                         }
                     } else {
                         $this->outall(sprintf(" | Task (%s) %s failed to execute, image file:%s not found!", $curTask->getID(), $curTask->getName(), $curTask->getImagePath()));
                     }
                 } else {
                     $runningTask = $this->getMCExistingTask($KnownTasks, $curTask->getID());
                     $curSession = new MulticastSessions($runningTask->getID());
                     $Assocs = $this->getClass('MulticastSessionsAssociationManager')->find(array('msID' => $curSession->get('id')));
                     foreach ($Assocs as $Assoc) {
                         if ($Assoc && $Assoc->isValid()) {
                             $curTaskGet = new Task($Assoc->get('taskID'));
                             if ($curTaskGet->get('stateID') == 5) {
                                 $jobcancelled = true;
                             }
                         }
                     }
                     if ($runningTask->isRunning()) {
                         $this->outall(sprintf(" | Task (%s) %s is already running PID %s", $runningTask->getID(), $runningTask->getName(), $runningTask->getPID()));
                         $runningTask->updateStats();
                     } else {
                         $this->outall(sprintf(" | Task (%s) %s is no longer running.", $runningTask->getID(), $runningTask->getName()));
                         if ($jobcancelled || $curSession->get('stateID') == 5) {
                             if ($runningTask->killTask()) {
                                 $KnownTasks = $this->removeFromKnownList($KnownTasks, $runningTask->getID());
                                 $this->outall(sprintf(" | Task (%s) %s has been cleaned as cancelled.", $runningTask->getID(), $runningTask->getName()));
                             } else {
                                 $this->outall(sprintf(" | Failed to kill task (%s) %s!", $runningTask->getID(), $runningTask->getName()));
                             }
                         } else {
                             $curSession->set('clients', 0)->set('completetime', $this->nice_date()->format('Y-m-d H:i:s'))->set('name', '')->set('stateID', 4)->save();
                             $KnownTasks = $this->removeFromKnownList($KnownTasks, $runningTask->getID());
                             $this->outall(sprintf(" | Task (%s) %s has been cleaned as complete.", $runningTask->getID(), $runningTask->getName()));
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             $this->outall($e->getMessage());
         }
         $this->FOGCore->out(sprintf(" +---------------------------------------------------------"), $this->dev);
         sleep(MULTICASTSLEEPTIME);
     }
 }
Ejemplo n.º 20
0
 /**
  * (non-PHPdoc)
  * @see BaseEntityAbstract::preSave()
  */
 public function preSave()
 {
     if (trim($this->getId()) === '') {
         if (!$this->status instanceof TaskStatus) {
             $this->setStatus(TaskStatus::get(TaskStatus::ID_NEW));
         }
         if (trim($this->getDueDate()) === trim(UDate::zeroDate())) {
             $this->setDueDate(UDate::now()->modify(self::DUE_DATE_PERIOD));
         }
     } else {
         $changed = array();
         $origTech = $origCustomer = $origOrder = $origStatus = null;
         $origTask = Task::get($this->getId());
         if (($customer = $this->getCustomer()) instanceof Customer && !($origCustomer = $origTask->getCustomer()) instanceof Customer || !$customer instanceof Customer && $origCustomer instanceof Customer || $customer instanceof Customer && $origCustomer instanceof Customer && $customer->getId() !== $origCustomer->getId()) {
             $changed[] = 'Customer Changed["' . ($origCustomer instanceof Customer ? $origCustomer->getName() : '') . '" => "' . ($customer instanceof Customer ? $customer->getName() : '') . '"]';
         }
         if (($tech = $this->getTechnician()) instanceof UserAccount && !($origTech = $origTask->getTechnician()) instanceof UserAccount || !$tech instanceof UserAccount && $origTech instanceof UserAccount || $tech instanceof UserAccount && $origTech instanceof UserAccount && $tech->getId() !== $origTech->getId()) {
             $changed[] = 'Technician Changed["' . ($origTech instanceof UserAccount ? $origTech->getPerson()->getFullName() : '') . '" => "' . ($tech instanceof UserAccount ? $tech->getPerson()->getFullName() : '') . '"]';
         }
         if (($order = $this->getFromEntity()) instanceof Order && !($origOrder = $origTask->getFromEntity()) instanceof Order || !$order instanceof Order && $origOrder instanceof Order || $order instanceof Order && $origOrder instanceof Order && $order->getId() !== $origOrder->getId()) {
             $changed[] = 'Order Changed["' . ($origOrder instanceof Order ? $origOrder->getOrderNo() : '') . '" => "' . ($order instanceof Order ? $order->getOrderNo() : '') . '"]';
         }
         if (($status = $this->getStatus()) instanceof TaskStatus && !($origStatus = $origTask->getStatus()) instanceof TaskStatus || !$status instanceof TaskStatus && $origStatus instanceof TaskStatus || $status instanceof TaskStatus && $origStatus instanceof TaskStatus && $status->getId() !== $origStatus->getId()) {
             $changed[] = 'Status Changed["' . ($origStatus instanceof TaskStatus ? $origStatus->getName() : '') . '" => "' . ($status instanceof TaskStatus ? $status->getName() : '') . '"]';
         }
         if (count($changed) > 0) {
             $this->addComment(implode(', ', $changed), Comments::TYPE_SYSTEM);
         }
     }
 }