213 lines
8.0 KiB
PHP
213 lines
8.0 KiB
PHP
|
|
<?PHP
|
||
|
|
|
||
|
|
/**
|
||
|
|
* *******************************************************************************
|
||
|
|
* SugarCRM Community Edition is a customer relationship management program developed by
|
||
|
|
* SugarCRM, Inc.
|
||
|
|
* Copyright (C) 2004-2013 SugarCRM Inc.
|
||
|
|
*
|
||
|
|
* This program is free software; you can redistribute it and/or modify it under
|
||
|
|
* the terms of the GNU Affero General Public License version 3 as published by the
|
||
|
|
* Free Software Foundation with the addition of the following permission added
|
||
|
|
* to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
|
||
|
|
* IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
|
||
|
|
* OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
|
||
|
|
*
|
||
|
|
* This program is distributed in the hope that it will be useful, but WITHOUT
|
||
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||
|
|
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
||
|
|
* details.
|
||
|
|
*
|
||
|
|
* You should have received a copy of the GNU Affero General Public License along with
|
||
|
|
* this program; if not, see http://www.gnu.org/licenses or write to the Free
|
||
|
|
* Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||
|
|
* 02110-1301 USA.
|
||
|
|
*
|
||
|
|
* You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
|
||
|
|
* SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
|
||
|
|
*
|
||
|
|
* The interactive user interfaces in modified source and object code versions
|
||
|
|
* of this program must display Appropriate Legal Notices, as required under
|
||
|
|
* Section 5 of the GNU Affero General Public License version 3.
|
||
|
|
*
|
||
|
|
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||
|
|
* these Appropriate Legal Notices must retain the display of the "Powered by
|
||
|
|
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
|
||
|
|
* technical reasons, the Appropriate Legal Notices must display the words
|
||
|
|
* "Powered by SugarCRM".
|
||
|
|
* ******************************************************************************
|
||
|
|
*/
|
||
|
|
|
||
|
|
/**
|
||
|
|
* THIS CLASS IS GENERATED BY MODULE BUILDER
|
||
|
|
* PLEASE DO NOT CHANGE THIS CLASS
|
||
|
|
* PLACE ANY CUSTOMIZATIONS IN EcmWorkCard
|
||
|
|
*/
|
||
|
|
class EcmWorkCard extends Basic {
|
||
|
|
|
||
|
|
var $new_schema = true;
|
||
|
|
var $module_dir = 'EcmWorkCards';
|
||
|
|
var $object_name = 'EcmWorkCard';
|
||
|
|
var $table_name = 'ecmworkcards';
|
||
|
|
var $importable = false;
|
||
|
|
var $disable_row_level_security = true; // to ensure that modules created and deployed under CE will continue to function under team security if the instance is upgraded to PRO
|
||
|
|
var $id;
|
||
|
|
var $name;
|
||
|
|
var $date_entered;
|
||
|
|
var $date_modified;
|
||
|
|
var $modified_user_id;
|
||
|
|
var $modified_by_name;
|
||
|
|
var $created_by;
|
||
|
|
var $created_by_name;
|
||
|
|
var $description;
|
||
|
|
var $deleted;
|
||
|
|
var $created_by_link;
|
||
|
|
var $modified_user_link;
|
||
|
|
var $assigned_user_id;
|
||
|
|
var $assigned_user_name;
|
||
|
|
var $assigned_user_link;
|
||
|
|
var $date;
|
||
|
|
var $work_name;
|
||
|
|
|
||
|
|
function EcmWorkCard() {
|
||
|
|
parent::Basic();
|
||
|
|
}
|
||
|
|
|
||
|
|
function bean_implements($interface) {
|
||
|
|
switch ($interface) {
|
||
|
|
case 'ACL' :
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
|
||
|
|
function save($check_notify = false) {
|
||
|
|
$this->name = $this->date . " " . $this->worker_name;
|
||
|
|
parent::save($check_notify);
|
||
|
|
$actionList = json_decode(base64_decode($_POST ['tableEcmActions_list']));
|
||
|
|
$action_array = array();
|
||
|
|
$i = 0;
|
||
|
|
foreach ($actionList as $value) {
|
||
|
|
if ($value->ecmproductid!= '') {
|
||
|
|
if($value->quantity != '0') {
|
||
|
|
$action_array [$i] ['ecmproductid'] = $value->ecmproductid;
|
||
|
|
$action_array [$i] ['ecmaction'] = $value->ecmaction;
|
||
|
|
$action_array [$i] ['quantity'] = $value->quantity;
|
||
|
|
$action_array [$i] ['ecmactioncost'] = $value->ecmactioncost;
|
||
|
|
$action_array [$i] ['costbrutto'] = $value->costbrutto;
|
||
|
|
$i = $i+1;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
$this->saveActionList($action_array);
|
||
|
|
}
|
||
|
|
|
||
|
|
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['WORKER_NAME']='<a href="index.php?module=EcmWorkers&action=DetailView&record='.$this->worker_id.'">'.$this->worker_name.'</a>';
|
||
|
|
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 : '[]';
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
?>
|