69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Libraries;
|
|
|
|
use App\Libraries\Crud_core;
|
|
use CodeIgniter\HTTP\RequestInterface;
|
|
|
|
class Crud extends Crud_core
|
|
{
|
|
function __construct($params, RequestInterface $request)
|
|
{
|
|
parent::__construct($params, $request);
|
|
}
|
|
|
|
function form()
|
|
{
|
|
return $this->parent_form();
|
|
}
|
|
|
|
public function callback_days_left($item){
|
|
$days = $this->days($item->p_end_date);
|
|
if($days < 0){
|
|
$out = '<span class="text-success">Completed</span>';
|
|
}else{
|
|
$out = '<span>' . $days . ' days left</span>';
|
|
}
|
|
|
|
return $out;
|
|
}
|
|
private function days($date)
|
|
{
|
|
$now = time(); // or your date as well
|
|
$your_date = strtotime($date);
|
|
$datediff = $your_date - $now;
|
|
|
|
return round($datediff / (60 * 60 * 24));
|
|
}
|
|
public function callback_featured_image($item){
|
|
$src = $item->p_image ? '/uploads/images/'.$item->p_image : '/admin/assets/img/profile.png';
|
|
|
|
return '<img src="'.$src.'" style="width:54px;" class="img-circle">';
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public function callback_OreStimate($item){
|
|
//$out = $this->OreLavorateByCommessa($item->coIDcommessa);
|
|
$out = $this->model->GetStimaByCommessa($item->coIDcommessa);
|
|
//if ($out>0) { return $out;}
|
|
if ($out>0) { return number_format($out,2);}
|
|
return number_format(0,2);
|
|
}
|
|
|
|
public function callback_OreLavorate($item){
|
|
//$out = $this->OreLavorateByCommessa($item->coIDcommessa);
|
|
$out = $this->model->GetOreByCommessa($item->coIDcommessa);
|
|
//if ($out>0) { return $out;}
|
|
if ($out>0) { return number_format($out,2);}
|
|
return number_format(0,2);
|
|
}
|
|
|
|
//private function OreLavorateByCommessa($idCommessa){
|
|
// return '<span>' . $idCommessa . '</span>';
|
|
//}
|
|
|
|
}
|