Announcement

Collapse
No announcement yet.

Set Task to QuoteItems and Query Calculate for dateStart/dateEnd?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Set Task to QuoteItems and Query Calculate for dateStart/dateEnd?

    How/Where can implement I updateHours() function to get the time difference of Task field name "tot_hours"?
    protected function updateHours(){
    $sql = "SELECT * FROM task";
    $res = "";
    if($res = $conn->query($sql) === false){
    throw new \Exception("UNABLE TO FETCH DATA");
    }
    $len = $res->num_rows;
    if($len > 0){
    while($row = $res->fetch_array(MYSQLI_ASSOC)){
    if($row['status'] == 'Completed' && empty($row['tot_hours']){
    $sql = "UPDATE task SET tot_hours = TIME_TO_SECT(TIMEDIFF(date_end,date_start))/3600 WHERE status = 'Completed'";
    $conn->query($sql) or throw new \Exception("UNABLE TO UPDATE");
    }
    else{
    continue;
    }

    }

    As well as assign the quoteitems to task?
    protected function setQuote(Entity $entity,array $options) { parent::afterSave($entity,$options); $entMan = $this->getEntityManager(); $task_name = $entMan->getEntity('Task','name'); $hour_rate = $entMan->getEntity('Account','hourlyRate'); $quote_name = $entMan->getEntity('Quote'); $quote_listprice = $entMan->getEntity('Quote'); $quote_unitprice = $entMan->getEntity('Quote'); $quote_name->set('name',$task_name); $quote_listprice->set('listprice',$hour_rate); $quote_unitprice->set('unitprice',$hour_rate); $entMan->saveEntity($entMan); }
Working...
X