diff --git a/htdocs/blockedlog/class/blockedlog.class.php b/htdocs/blockedlog/class/blockedlog.class.php index cb36c4cd4f7..b64524569c6 100644 --- a/htdocs/blockedlog/class/blockedlog.class.php +++ b/htdocs/blockedlog/class/blockedlog.class.php @@ -383,12 +383,24 @@ class BlockedLog // Set object_data $this->object_data=new stdClass(); + // Add fields to exclude $arrayoffieldstoexclude = array( - 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf', + 'table_element','fields','ref_previous','ref_next','origin','origin_id','oldcopy','picto','error','errors','modelpdf','civility_id','contact','contact_id', 'table_element_line','ismultientitymanaged','isextrafieldmanaged', 'linkedObjectsIds','linkedObjects','fk_delivery_address', - 'context' + 'context', + 'projet' // There is already ->fk_project ); + // Add more fields to exclude depending on object type + if ($this->element == 'cashcontrol') + { + $arrayoffieldstoexclude = array_merge($arrayoffieldstoexclude, array( + 'name','lastname','firstname','region','region_id','region_code','state','state_id','state_code','country','country_id','country_code', + 'total_ht','total_tva','total_ttc','total_localtax1','total_localtax2', + 'barcode_type','barcode_type_code','barcode_type_label','barcode_type_coder','mode_reglement_id','cond_reglement_id','mode_reglement','cond_reglement','shipping_method_id', + 'fk_incoterms','libelle_incoterms','location_incoterms','lines') + ); + } // Add thirdparty info if (empty($object->thirdparty) && method_exists($object, 'fetch_thirdparty')) $object->fetch_thirdparty(); diff --git a/htdocs/compta/cashcontrol/cashcontrol_card.php b/htdocs/compta/cashcontrol/cashcontrol_card.php index 6d446580353..d494b5777f2 100644 --- a/htdocs/compta/cashcontrol/cashcontrol_card.php +++ b/htdocs/compta/cashcontrol/cashcontrol_card.php @@ -1,6 +1,4 @@ * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin @@ -33,7 +31,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/cashcontrol/class/cashcontrol.class.php'; -$langs->loadLangs(array("cashcontrol","install","cashdesk","admin","banks")); +$langs->loadLangs(array("install","cashdesk","admin","banks")); $id=GETPOST('id','int'); $ref = GETPOST('ref', 'alpha'); @@ -84,16 +82,23 @@ $hookmanager->initHooks(array('cashcontrolcard','globalcard')); * Actions */ +$permissiontoadd = ($user->rights->cashdesk->use || $user->rights->takepos->use); +$permissiontodelete = ($user->rights->cashdesk->use || $user->rights->takepos->use) || ($permissiontoadd && $object->status == 0); +if (empty($backtopage)) $backtopage = dol_buildpath('/compta/cashcontrol/cashcontrol_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); +$backurlforlist = dol_buildpath('/compta/cashcontrol/cashcontrol_list.php',1); +$triggermodname = 'CACHCONTROL_MODIFY'; // Name of trigger action code to execute when we modify record + if (empty($conf->global->CASHDESK_ID_BANKACCOUNT_CASH)) { setEventMessages($langs->trans("CashDesk")." - ".$langs->trans("NotConfigured"), null, 'errors'); } -if (GETPOST('cancel')) +if (GETPOST('cancel','alpha')) { $action = 'create'; } + if ($action=="start") { $error=0; @@ -127,7 +132,7 @@ elseif ($action=="add") $error=0; foreach($arrayofpaymentmode as $key=>$val) { - if (GETPOST($key,'alpha') == '') + if (GETPOST($key.'_amount','alpha') == '') { setEventMessages($langs->trans("ErrorFieldRequired", $langs->transnoentitiesnoconv($val)), null, 'errors'); $action='start'; @@ -135,7 +140,7 @@ elseif ($action=="add") } else { - $object->$key = price2num(GETPOST($key,'alpha')); + $object->$key = price2num(GETPOST($key.'_amount','alpha')); } } @@ -183,6 +188,32 @@ if ($action=="close") $action="view"; } +// Action to delete +if ($action == 'confirm_delete' && ! empty($permissiontodelete)) +{ + $object->fetch($id); + + if (! ($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + + $result=$object->delete($user); + var_dump($result); + if ($result > 0) + { + // Delete OK + setEventMessages("RecordDeleted", null, 'mesgs'); + header("Location: ".$backurlforlist); + exit; + } + else + { + if (! empty($object->errors)) setEventMessages(null, $object->errors, 'errors'); + else setEventMessages($object->error, null, 'errors'); + } +} /* @@ -414,7 +445,7 @@ if ($action=="create" || $action=="start") foreach($arrayofpaymentmode as $key => $val) { print ''; - print ''; + print ''; print ''; $i++; } @@ -493,16 +524,12 @@ if (empty($action) || $action=="view") print price($object->opening, 0, $langs, 1, -1, -1, $conf->currency); print ""; - print ''.$langs->trans("Cash").''; - print price($object->cash, 0, $langs, 1, -1, -1, $conf->currency); - print ""; - print ''.$langs->trans("Cheque").''; - print price($object->cheque, 0, $langs, 1, -1, -1, $conf->currency); - print ""; - print ''.$langs->trans("Card").''; - print price($object->card, 0, $langs, 1, -1, -1, $conf->currency); - print ""; - + foreach($arrayofpaymentmode as $key => $val) + { + print ''.$langs->trans($val).''; + print price($object->$key, 0, $langs, 1, -1, -1, $conf->currency); + print ""; + } print "\n"; print ''; @@ -516,6 +543,8 @@ if (empty($action) || $action=="view") if ($object->status == CashControl::STATUS_DRAFT) { print ''; + + print ''; } print ''; diff --git a/htdocs/compta/cashcontrol/class/cashcontrol.class.php b/htdocs/compta/cashcontrol/class/cashcontrol.class.php index fdf77b17961..071be33fd1f 100644 --- a/htdocs/compta/cashcontrol/class/cashcontrol.class.php +++ b/htdocs/compta/cashcontrol/class/cashcontrol.class.php @@ -276,6 +276,18 @@ class CashControl extends CommonObject return $result; } + /** + * Delete object in database + * + * @param User $user User that deletes + * @param bool $notrigger false=launch triggers after, true=disable triggers + * @return int <0 if KO, >0 if OK + */ + public function delete(User $user, $notrigger = false) + { + return $this->deleteCommon($user, $notrigger); + //return $this->deleteCommon($user, $notrigger, 1); + } /** * Return label of the status diff --git a/htdocs/compta/cashcontrol/report.php b/htdocs/compta/cashcontrol/report.php index c85e48f09e7..a2187e3b344 100644 --- a/htdocs/compta/cashcontrol/report.php +++ b/htdocs/compta/cashcontrol/report.php @@ -286,7 +286,7 @@ if ($resql) print "

"; print $langs->trans("Cash").": ".price($cash)."

"; print $langs->trans("PaymentTypeCB").": ".price($bank)."

"; - print $langs->trans("PaymentTypeCheque").": ".price($cheque)."

"; + print $langs->trans("PaymentTypeCHQ").": ".price($cheque)."

"; print "

"; //save totals to DB diff --git a/htdocs/core/actions_addupdatedelete.inc.php b/htdocs/core/actions_addupdatedelete.inc.php index 31a6549cc27..b8b4237cc93 100644 --- a/htdocs/core/actions_addupdatedelete.inc.php +++ b/htdocs/core/actions_addupdatedelete.inc.php @@ -149,6 +149,7 @@ if ($action == 'update' && ! empty($permissiontoadd)) if ($action == "update_extras" && ! empty($permissiontoadd)) { $object->fetch(GETPOST('id','int')); + $attributekey = GETPOST('attribute','alpha'); $attributekeylong = 'options_'.$attributekey; $object->array_options['options_'.$attributekey] = GETPOST($attributekeylong,' alpha'); @@ -169,6 +170,12 @@ if ($action == "update_extras" && ! empty($permissiontoadd)) // Action to delete if ($action == 'confirm_delete' && ! empty($permissiontodelete)) { + if (! ($object->id > 0)) + { + dol_print_error('', 'Error, object must be fetched before being deleted'); + exit; + } + $result=$object->delete($user); if ($result > 0) { diff --git a/htdocs/langs/en_US/cashdesk.lang b/htdocs/langs/en_US/cashdesk.lang index 73b2b4f6b37..ba14b343954 100644 --- a/htdocs/langs/en_US/cashdesk.lang +++ b/htdocs/langs/en_US/cashdesk.lang @@ -42,4 +42,7 @@ Place=Place TakeposConnectorNecesary='TakePOS Connector' required OrderPrinters=Order printers SearchProduct=Search product -AmountAtEndOfPeriod=Amount at end of period (day, month or year) \ No newline at end of file +AmountAtEndOfPeriod=Amount at end of period (day, month or year) +TheoricalAmount=Theorical amount +RealAmount=Real amount +CashFenceDone=Cash fence done for the period \ No newline at end of file diff --git a/htdocs/modulebuilder/template/myobject_card.php b/htdocs/modulebuilder/template/myobject_card.php index f9b3db7a99e..84a23ab979d 100644 --- a/htdocs/modulebuilder/template/myobject_card.php +++ b/htdocs/modulebuilder/template/myobject_card.php @@ -118,7 +118,7 @@ if (empty($reshook)) $error=0; $permissiontoadd = $user->rights->mymodule->write; - $permissiontodelete = $user->rights->mymodule->delete; + $permissiontodelete = $user->rights->mymodule->delete || ($permissiontoadd && $object->status == 0); if (empty($backtopage)) $backtopage = dol_buildpath('/mymodule/myobject_card.php',1).'?id='.($id > 0 ? $id : '__ID__'); $backurlforlist = dol_buildpath('/mymodule/myobject_list.php',1); $triggermodname = 'MYMODULE_MYOBJECT_MODIFY'; // Name of trigger action code to execute when we modify record