name = $this->date . " " . $this->worker_name;
$this->quantity=str_replace(",",".",str_replace(".","",$this->quantity));
parent::save($check_notify);
if($_REQUEST['create_new']=="1"){
header("Location: index.php?module=EcmWorkCards&action=EditView&date=".date("d.m.Y",strtotime($this->date)));
die();
}
}
function create_new_list_query($order_by, $where, $parentbean, $filter = array(), $params = array(), $show_deleted = 0, $join_type = '', $return_array = false, $singleSelect = false){
global $current_user;
$ret_array = parent::create_new_list_query($order_by, $where,$filter,$params, $show_deleted,$join_type, $return_array,$parentbean, $singleSelect);
// filtrowanie po dacie od do
// filtrowanie po dacie od do
$ret_array['where'] = str_replace("ecmworkcards.date_start =", "ecmworkcards.date > ", $ret_array['where']);
$ret_array['where'] = str_replace("ecmworkcards.date_end =", "ecmworkcards.date < ", $ret_array['where']);
return $ret_array;
}
function get_list_view_data() {
$array = parent::get_list_view_data();
$this->retrieve($this->id);
$array['DATE'] = $this->date;
$array['TIME_FROM'] = $this->time_from.' - '.$this->time_to;
$array['DESCRIPTION'] = $this->description;
$array['QUANTITY'] = $this->quantity;
$array['WORKER_NAME']=''.$this->worker_name.'';
$array['PRODUCT_NAME']=''.$this->product_name.'';
$array['ACTION_NAME']=''.$this->action_name.'';
return $array;
}
function saveActionList($pl) {
global $current_user;
$exists = array();
if ($this->id != '') {
$GLOBALS ['db']->query("DELETE FROM ecmworkcards_ecmaction WHERE ecmworkcards='" . $this->id . "'");
}
foreach ($pl as $p) {
// insert new record
$id = create_guid();
$t = array(
$id,
$this->id,
$current_user->id,
$this->date_modified,
addslashes($p ['ecmproductid']),
addslashes($p ['ecmaction']),
addslashes($p ['quantity']),
addslashes($p ['ecmactioncost']),
addslashes($p ['costbrutto']),
);
$q = "INSERT INTO ecmworkcards_ecmaction VALUES ('" . implode("','", $t) . "')";
$GLOBALS ['db']->query($q);
$exists [] = $id;
}
}
function getActionList($array = false) {
if (isset($this->id) && $this->id != '') {
$query = "SELECT
a.ecmproduct AS ecmproductid,
a.ecmaction AS ecmaction,
a.quantity AS quantity,
b.code AS code,
b.name AS ecmproductname,
c.name AS ecmaction_name,
c.indeks AS ecmaction_indeks,
a.ecmactioncost AS ecmactioncost,
a.costbrutto AS costbrutto,
IFNULL(a.ecmactioncost*a.quantity,'0,00') AS ecmactioncost_display,
IFNULL(a.costbrutto*a.quantity,'0,00') AS costbrutto_display
FROM
ecmworkcards_ecmaction a
INNER JOIN
ecmproducts b ON b.id = a.ecmproduct
LEFT JOIN
ecmactions c ON c.id = a.ecmaction
WHERE
a.ecmproduct = b.id
AND a.ecmworkcards ='" . $this->id . "' ORDER BY b.code";
$r = $this->db->query($query);
$return_array = array();
if ($r) {
while ($row = $this->db->fetchByAssoc($r)) {
$a_json_row ['ecmproductid'] = $row ['ecmproductid'];
$a_json_row ['ecmaction'] = $row ['ecmaction'];
$a_json_row ['ecmaction_name'] = $row ['ecmaction_name'];
$a_json_row ['ecmaction_indeks'] = $row ['ecmaction_indeks'];
$a_json_row ['quantity'] = $row ['quantity'];
$a_json_row ['code'] = $row ['code'];
$a_json_row ['ecmactioncost_display'] = format_number($row ['ecmactioncost_display']);
$a_json_row ['ecmactioncost'] = $row ['ecmactioncost'];
$a_json_row ['ecmproductname'] = $row ['ecmproductname'];
$a_json_row ['costbrutto_display'] = format_number($row ['costbrutto_display']);
$a_json_row ['costbrutto'] = $row ['costbrutto'];
$a_json_row ['ecmactioncost_single_netto'] = format_number($row ['ecmactioncost']);
$a_json_row ['ecmactioncost_single_brutto'] = format_number($row ['costbrutto']);
$a_json_row ['produkt'] = array();
$a_json_row ['produkt'][0] = $row ['code'];
$a_json_row ['produkt'][1] =$row ['ecmproductname'];
$a_json_row ['produkt'][2] = $row ['ecmproductid'];
$a_json_row ['czynnosc'] = array();
$a_json_row ['czynnosc'][0] = $row ['ecmaction_indeks'];
$a_json_row ['czynnosc'][1] =$row ['ecmaction_name'];
$a_json_row ['czynnosc'][2] = $row ['ecmaction'];
$a_json_row ['netto'] = array();
$a_json_row ['netto'][0] = format_number($row ['ecmactioncost']);
$a_json_row ['netto'][1] =format_number($row ['ecmactioncost_display']);
$a_json_row ['brutto'] = array();
$a_json_row ['brutto'][0] = format_number($row ['costbrutto']);
$a_json_row ['brutto'][1] = format_number($row ['costbrutto_display']);
$return_array [] = $a_json_row;
}
return $array ? base64_encode(json_encode($return_array)) : base64_encode(json_encode($return_array));
}
}
return $array ? false : '[]';
}
}
?>