diff --git a/dev/examples/create_product.php b/dev/examples/create_product.php index 8fe36260c98..cdb6cdae9e2 100755 --- a/dev/examples/create_product.php +++ b/dev/examples/create_product.php @@ -70,7 +70,7 @@ $myproduct->libelle = 'libelle'; $myproduct->price = '10'; $myproduct->price_base_type = 'HT'; $myproduct->tva_tx = '19.6'; -$myproduct->type = 0; +$myproduct->type = Product::TYPE_PRODUCT; $myproduct->status = 1; $myproduct->description = 'Description'; $myproduct->note = 'Note'; diff --git a/htdocs/admin/supplier_order.php b/htdocs/admin/supplier_order.php index 5be30f08ee3..fb9ac6fa39c 100644 --- a/htdocs/admin/supplier_order.php +++ b/htdocs/admin/supplier_order.php @@ -165,13 +165,24 @@ else if ($action == 'addcat') $fourn->CreateCategory($user,$_POST["cat"]); } -else if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT') +else if ($action == 'set_SUPPLIER_ORDER_OTHER') { $freetext = GETPOST('SUPPLIER_ORDER_FREE_TEXT'); // No alpha here, we want exact string - - $res = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); - - if (! $res > 0) $error++; + $doubleapproval = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL'); + $doubleapprovalgroup = GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP') > 0 ? GETPOST('SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP') : ''; + + $res1 = dolibarr_set_const($db, "SUPPLIER_ORDER_FREE_TEXT",$freetext,'chaine',0,'',$conf->entity); + $res2 = dolibarr_set_const($db, "SUPPLIER_ORDER_DOUBLE_APPROVAL",$doubleapproval,'chaine',0,'',$conf->entity); + if (isset($_POST["SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP"])) + { + $res3 = dolibarr_set_const($db, "SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP",$doubleapprovalgroup,'chaine',0,'',$conf->entity); + } + else + { + $res3=1; + } + + if (! $res1 > 0 || ! $res2 > 0 || ! $res3 > 0) $error++; if (! $error) { @@ -188,12 +199,12 @@ else if ($action == 'set_SUPPLIER_ORDER_FREE_TEXT') * View */ +$form=new Form($db); + $dirmodels=array_merge(array('/'),(array) $conf->modules_parts['models']); llxHeader("",""); -$form=new Form($db); - $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("SuppliersSetup"),$linkback,'setup'); @@ -447,7 +458,7 @@ print '
'; print '
'; print ''; -print ''; +print ''; print_titre($langs->trans("OtherOptions")); print ''; @@ -457,6 +468,17 @@ print ''; print ''; print "\n"; +if ($conf->global->MAIN_FEATURES_LEVEL > 0) +{ + print '\n"; +} + print ''; print '\n"; - if (($fac->statut == 3 ) || ($fac->statut == 2 && ! $fact->close_code) ) $solde = $solde = $solde + $totalpaye; + if (($fac->statut == Facture::STATUS_ABANDONED ) || ($fac->statut == Facture::STATUS_CLOSED && ! $fact->close_code) ) $solde = $solde = $solde + $totalpaye; else $solde = $solde + $fac->total_ttc; print ''; diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0a2c39abbe8..3457e8eed74 100644 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -74,11 +74,11 @@ class ExtraFields 'mail'=>'ExtrafieldMail', 'select' => 'ExtrafieldSelect', 'sellist' => 'ExtrafieldSelectList', - 'separate' => 'ExtrafieldSeparator', - 'checkbox' => 'ExtrafieldCheckBox', 'radio' => 'ExtrafieldRadio', + 'checkbox' => 'ExtrafieldCheckBox', 'chkbxlst' => 'ExtrafieldCheckBoxFromList', 'link' => 'ExtrafieldLink', + 'separate' => 'ExtrafieldSeparator', ); /** diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index ae7b0e2d1e8..eb63f76319f 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -3872,7 +3872,7 @@ class Form { $prodstatic=new Product($this->db); $prodstatic->fetch($idprod); - if ($prodstatic->type == 1) // We know product is a service + if ($prodstatic->type == Product::TYPE_SERVICE) // We know product is a service { $code_country.=",'".$societe_acheteuse->country_code."'"; } diff --git a/htdocs/core/lib/donation.lib.php b/htdocs/core/lib/donation.lib.php index ed6407b1e84..1fdd2399610 100644 --- a/htdocs/core/lib/donation.lib.php +++ b/htdocs/core/lib/donation.lib.php @@ -27,7 +27,7 @@ * @param Donation $object Donation * @return array Array of tabs to show */ -function donation_admin_prepare_head() +function donation_admin_prepare_head($object) { global $langs, $conf; diff --git a/htdocs/core/menus/init_menu_auguria.sql b/htdocs/core/menus/init_menu_auguria.sql index ffb33138bcc..f481abdcf0c 100644 --- a/htdocs/core/menus/init_menu_auguria.sql +++ b/htdocs/core/menus/init_menu_auguria.sql @@ -17,7 +17,7 @@ insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, left insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('projet', '$conf->projet->enabled', 7__+MAX_llx_menu__, __HANDLER__, 'top', 'project', '', 0, '/projet/index.php?mainmenu=project&leftmenu=', 'Projects', -1, 'projects', '$user->rights->projet->lire', '', 2, 70, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('mailing|export|import|opensurvey', '$conf->mailing->enabled || $conf->export->enabled || $conf->import->enabled || $conf->opensurvey->enabled', 8__+MAX_llx_menu__, __HANDLER__, 'top', 'tools', '', 0, '/core/tools.php?mainmenu=tools&leftmenu=', 'Tools', -1, 'other', '$user->rights->mailing->lire || $user->rights->export->lire || $user->rights->import->run || $user->rights->opensurvey->read', '', 2, 90, __ENTITY__); insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('adherent', '$conf->adherent->enabled', 13__+MAX_llx_menu__, __HANDLER__, 'top', 'members', '', 0, '/adherents/index.php?mainmenu=members&leftmenu=', 'Members', -1, 'members', '$user->rights->adherent->lire', '', 2, 110, __ENTITY__); -insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm', '$conf->holiday->enabled || $conf->deplacement->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/compta/hrm.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->holiday->write || $user->rights->deplacement->lire', '', 0, 80, __ENTITY__); +insert into llx_menu (module, enabled, rowid, menu_handler, type, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('hrm', '$conf->holiday->enabled || $conf->deplacement->enabled || $conf->expensereport->enabled', 15__+MAX_llx_menu__, __HANDLER__, 'top', 'hrm', '', 0, '/compta/hrm.php?mainmenu=hrm&leftmenu=', 'HRM', -1, 'holiday', '$user->rights->holiday->write || $user->rights->deplacement->lire || $user->rights->expensereport->lire', '', 0, 80, __ENTITY__); -- Home - Setup insert into llx_menu (module, enabled, menu_handler, type, rowid, mainmenu, leftmenu, fk_menu, url, titre, level, langs, perms, target, usertype, position, entity) values ('', '$user->admin', __HANDLER__, 'left', 100__+MAX_llx_menu__, 'home', 'setup', 1__+MAX_llx_menu__, '/admin/index.php?leftmenu=setup', 'Setup', 0, 'admin', '', '', 2, 0, __ENTITY__); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index 9eba6b79dd6..d6ee928b121 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -196,9 +196,9 @@ function print_eldy_menu($db,$atarget,$type_user,&$tabMenu,&$menu,$noout=0) } // HRM - $tmpentry=array('enabled'=>(! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled)), - 'perms'=>(! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire)), - 'module'=>'holiday|deplacement'); + $tmpentry=array('enabled'=>(! empty($conf->holiday->enabled) || ! empty($conf->deplacement->enabled) || ! empty($conf->expensereport->enabled)), + 'perms'=>(! empty($user->rights->holiday->write) || ! empty($user->rights->deplacement->lire) || ! empty($user->rights->expensereport->lire)), + 'module'=>'holiday|deplacement|expensereport'); $showmode=dol_eldy_showmenu($type_user, $tmpentry, $listofmodulesforexternal); if ($showmode) { diff --git a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php index c266bd38347..eb26e9bd32c 100644 --- a/htdocs/core/modules/facture/doc/pdf_crabe.modules.php +++ b/htdocs/core/modules/facture/doc/pdf_crabe.modules.php @@ -1216,7 +1216,7 @@ class pdf_crabe extends ModelePDFFactures } // Escompte - if ($object->close_code == 'discount_vat') + if ($object->close_code == Facture::CLOSECODE_DISCOUNTVAT) { $index++; $pdf->SetFillColor(255,255,255); diff --git a/htdocs/core/modules/modDon.class.php b/htdocs/core/modules/modDon.class.php index 8c7425ceed2..e25bd6d3bf9 100644 --- a/htdocs/core/modules/modDon.class.php +++ b/htdocs/core/modules/modDon.class.php @@ -104,6 +104,13 @@ class modDon extends DolibarrModules "Message affiché sur le récépissé de versements ou dons", "0" ); + $this->const[5] = array ( + "DONATION_ACCOUNTINGACCOUNT", + "chaine", + "7581", + "Compte comptable de remise des versements ou dons", + "0" + ); // Boxes $this->boxes = array(); diff --git a/htdocs/core/photos_resize.php b/htdocs/core/photos_resize.php index 3a51a5f7567..80f849a0494 100644 --- a/htdocs/core/photos_resize.php +++ b/htdocs/core/photos_resize.php @@ -70,8 +70,8 @@ if ($id > 0) $result = $object->fetch($id); if ($result <= 0) dol_print_error($db,'Failed to load object'); $dir=$conf->product->multidir_output[$object->entity]; // By default - if ($object->type == 0) $dir=$conf->product->multidir_output[$object->entity]; - if ($object->type == 1) $dir=$conf->service->multidir_output[$object->entity]; + if ($object->type == Product::TYPE_PRODUCT) $dir=$conf->product->multidir_output[$object->entity]; + if ($object->type == Product::TYPE_SERVICE) $dir=$conf->service->multidir_output[$object->entity]; } /* diff --git a/htdocs/core/tpl/admin_extrafields_add.tpl.php b/htdocs/core/tpl/admin_extrafields_add.tpl.php index 72eddc012d2..f5e6c957b1a 100644 --- a/htdocs/core/tpl/admin_extrafields_add.tpl.php +++ b/htdocs/core/tpl/admin_extrafields_add.tpl.php @@ -15,6 +15,14 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ + +/** + * The following vars must be defined + * $type2label + * $form + * $conf, $lang, + */ + ?> @@ -47,13 +55,13 @@ else if (type == 'varchar') { size.val('255').removeAttr('disabled'); unique.removeAttr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide(); } else if (type == 'boolean') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} else if (type == 'price') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();} - else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();} - else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpchkbxlst").hide();} - else if (type == 'chkbxlst') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide(); jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();} + else if (type == 'select') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'link') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();;jQuery("#helpchkbxlst").hide();jQuery("#helplink").show();} + else if (type == 'sellist') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").show();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'radio') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'checkbox') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").show();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} + else if (type == 'chkbxlst') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); jQuery("#value_choice").show();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").show();jQuery("#helplink").hide();} + else if (type == 'separate') { size.val('').attr('disabled','disabled'); unique.attr('disabled','disabled'); required.val('').attr('disabled','disabled'); default_value.val('').attr('disabled','disabled'); jQuery("#value_choice").hide();jQuery("#helpselect").hide();jQuery("#helpsellist").hide();jQuery("#helpchkbxlst").hide();jQuery("#helplink").hide();} else size.val('').attr('disabled','disabled'); } init_typeoffields(''); @@ -66,7 +74,6 @@ " method="post"> -
'.$langs->trans("Value").' 
'; + print $langs->trans("UseDoubleApproval").''; + print $form->selectyesno('SUPPLIER_ORDER_DOUBLE_APPROVAL', $conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL); + print '
'.$form->select_dolgroups($conf->global->SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP,'SUPPLIER_ORDER_DOUBLE_APPROVAL_GROUP', 1); + print '
'; + print ''; + print "
'; print $langs->trans("FreeLegalTextOnOrders").' ('.$langs->trans("AddCRIfTooLong").')
'; print ''; diff --git a/htdocs/categories/admin/categorie_extrafields.php b/htdocs/categories/admin/categorie_extrafields.php index c57fae8c311..632c9c4dff9 100644 --- a/htdocs/categories/admin/categorie_extrafields.php +++ b/htdocs/categories/admin/categorie_extrafields.php @@ -49,6 +49,7 @@ if (!$user->admin) accessforbidden(); /* * Actions */ + require DOL_DOCUMENT_ROOT.'/core/actions_extrafields.inc.php'; diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index e116ac668ab..76af3708c8b 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -343,7 +343,7 @@ else if ($id || $ref) $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); + $picto=($product->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'category', $titre,0,$picto); diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php index c091817d606..206de4d523c 100644 --- a/htdocs/commande/card.php +++ b/htdocs/commande/card.php @@ -144,7 +144,7 @@ if (empty($reshook)) // Reopen a closed order else if ($action == 'reopen' && $user->rights->commande->creer) { - if ($object->statut == 3) + if ($object->statut == Commande::STATUS_CLOSED) { $result = $object->set_reopen($user); if ($result > 0) @@ -1810,7 +1810,7 @@ if ($action == 'create' && $user->rights->commande->creer) $absolute_discount = price2num($absolute_discount, 'MT'); $absolute_creditnote = price2num($absolute_creditnote, 'MT'); if ($absolute_discount) { - if ($object->statut > 0) { + if ($object->statut > Commande::STATUS_DRAFT) { print $langs->trans("CompanyHasAbsoluteDiscount", price($absolute_discount), $langs->transnoentities("Currency" . $conf->currency)); } else { // Remise dispo de type remise fixe (not credit note) @@ -2105,7 +2105,7 @@ if ($action == 'create' && $user->rights->commande->creer) '; - if (! empty($conf->use_javascript_ajax) && $object->statut == 0) { + if (! empty($conf->use_javascript_ajax) && $object->statut == Commande::STATUS_DRAFT) { include DOL_DOCUMENT_ROOT . '/core/tpl/ajaxrow.tpl.php'; } @@ -2120,7 +2120,7 @@ if ($action == 'create' && $user->rights->commande->creer) /* * Form to add new line */ - if ($object->statut == 0 && $user->rights->commande->creer) + if ($object->statut == Commande::STATUS_DRAFT && $user->rights->commande->creer) { if ($action != 'editline') { @@ -2150,7 +2150,7 @@ if ($action == 'create' && $user->rights->commande->creer) // modified by hook if (empty($reshook)) { // Valid - if ($object->statut == 0 && $object->total_ttc >= 0 && $numlines > 0 && + if ($object->statut == Commande::STATUS_DRAFT && $object->total_ttc >= 0 && $numlines > 0 && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->creer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->validate))) ) @@ -2158,7 +2158,7 @@ if ($action == 'create' && $user->rights->commande->creer) print ''; } // Edit - if ($object->statut == 1 && $user->rights->commande->creer) { + if ($object->statut == Commande::STATUS_VALIDATED && $user->rights->commande->creer) { print ''; } // Create event @@ -2169,7 +2169,7 @@ if ($action == 'create' && $user->rights->commande->creer) print '' . $langs->trans("AddAction") . ''; } // Send - if ($object->statut > 0) { + if ($object->statut > Commande::STATUS_DRAFT) { if ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) || $user->rights->commande->order_advance->send)) { print ''; } else @@ -2181,7 +2181,7 @@ if ($action == 'create' && $user->rights->commande->creer) if (! empty($conf->expedition->enabled)) { $numshipping = $object->nb_expedition(); - if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfProductsLines() > 0) { + if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfProductsLines() > 0) { if (($conf->expedition_bon->enabled && $user->rights->expedition->creer) || ($conf->livraison_bon->enabled && $user->rights->expedition->livraison->creer)) { if ($user->rights->expedition->creer) { print ''; @@ -2199,7 +2199,7 @@ if ($action == 'create' && $user->rights->commande->creer) if ($conf->ficheinter->enabled) { $langs->load("interventions"); - if ($object->statut > 0 && $object->statut < 3 && $object->getNbOfServicesLines() > 0) { + if ($object->statut > Commande::STATUS_DRAFT && $object->statut < Commande::STATUS_CLOSED && $object->getNbOfServicesLines() > 0) { if ($user->rights->ficheinter->creer) { print ''; } else { @@ -2209,12 +2209,12 @@ if ($action == 'create' && $user->rights->commande->creer) } // Reopen a closed order - if ($object->statut == 3 && $user->rights->commande->creer) { + if ($object->statut == Commande::STATUS_CLOSED && $user->rights->commande->creer) { print ''; } // Create contract - if ($conf->contrat->enabled && ($object->statut == 1 || $object->statut == 2)) { + if ($conf->contrat->enabled && ($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED)) { $langs->load("contracts"); if ($user->rights->contrat->creer) { @@ -2224,17 +2224,17 @@ if ($action == 'create' && $user->rights->commande->creer) // Create bill and Classify billed // Note: Even if module invoice is not enabled, we should be able to use button "Classified billed" - if ($object->statut > 0 && ! $object->billed) { + if ($object->statut > Commande::STATUS_DRAFT && ! $object->billed) { if (! empty($conf->facture->enabled) && $user->rights->facture->creer && empty($conf->global->WORKFLOW_DISABLE_CREATE_INVOICE_FROM_ORDER)) { print ''; } - if ($user->rights->commande->creer && $object->statut > 2 && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { + if ($user->rights->commande->creer && $object->statut > Commande::STATUS_ACCEPTED && empty($conf->global->WORKFLOW_DISABLE_CLASSIFY_BILLED_FROM_ORDER) && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT)) { print ''; } } // Set to shipped - if (($object->statut == 1 || $object->statut == 2) && $user->rights->commande->cloturer) { + if (($object->statut == Commande::STATUS_VALIDATED || $object->statut == Commande::STATUS_ACCEPTED) && $user->rights->commande->cloturer) { print ''; } @@ -2244,7 +2244,7 @@ if ($action == 'create' && $user->rights->commande->creer) } // Cancel order - if ($object->statut == 1 && + if ($object->statut == Commande::STATUS_VALIDATED && ((empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->cloturer)) || (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! empty($user->rights->commande->order_advance->annuler))) ) diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index ac567742f0f..1a5d8bf2ceb 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -60,10 +60,39 @@ class Commande extends CommonOrder var $ref_int; var $contactid; var $fk_project; - var $statut; // -1=Canceled, 0=Draft, 1=Validated, (2=Accepted/On process not managed for customer orders), 3=Closed (Sent/Received, billed or not) + /** + * Status of the order. Check the following constants: + * - STATUS_CANCELED + * - STATUS_DRAFT + * - STATUS_ACCEPTED + * - STATUS_CLOSED + * @var int + */ + var $statut; var $facturee; // deprecated var $billed; // billed or not + /** + * Canceled status + */ + const STATUS_CANCELED = -1; + /** + * Draft status + */ + const STATUS_DRAFT = 0; + /** + * Validated status + */ + const STATUS_VALIDATED = 1; + /** + * Accepted/On process not managed for customer orders + */ + const STATUS_ACCEPTED = 2; + /** + * Closed (Sent/Received, billed or not) + */ + const STATUS_CLOSED = 3; + var $brouillon; var $cond_reglement_id; var $cond_reglement_code; @@ -212,7 +241,7 @@ class Commande extends CommonOrder $error=0; // Protection - if ($this->statut == 1) + if ($this->statut == self::STATUS_VALIDATED) { dol_syslog(get_class($this)."::valid no draft status", LOG_WARNING); return 0; @@ -251,7 +280,7 @@ class Commande extends CommonOrder // Validate $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql.= " SET ref = '".$num."',"; - $sql.= " fk_statut = 1,"; + $sql.= " fk_statut = ".self::STATUS_VALIDATED.","; $sql.= " date_valid='".$this->db->idate($now)."',"; $sql.= " fk_user_valid = ".$user->id; $sql.= " WHERE rowid = ".$this->id; @@ -341,7 +370,7 @@ class Commande extends CommonOrder if (! $error) { $this->ref = $num; - $this->statut = 1; + $this->statut = self::STATUS_VALIDATED; } if (! $error) @@ -370,7 +399,7 @@ class Commande extends CommonOrder $error=0; // Protection - if ($this->statut <= 0) + if ($this->statut <= self::STATUS_DRAFT) { return 0; } @@ -385,7 +414,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET fk_statut = 0"; + $sql.= " SET fk_statut = ".self::STATUS_DRAFT; $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::set_draft", LOG_DEBUG); @@ -411,7 +440,7 @@ class Commande extends CommonOrder if (!$error) { - $this->statut=0; + $this->statut=self::STATUS_DRAFT; $this->db->commit(); return $result; } @@ -423,7 +452,7 @@ class Commande extends CommonOrder } } - $this->statut=0; + $this->statut=self::STATUS_DRAFT; $this->db->commit(); return 1; } @@ -448,7 +477,7 @@ class Commande extends CommonOrder global $conf,$langs; $error=0; - if ($this->statut != 3) + if ($this->statut != self::STATUS_CLOSED) { dol_syslog(get_class($this)."::set_reopen order has not status closed", LOG_WARNING); return 0; @@ -457,7 +486,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql.= ' SET fk_statut=1, facture=0'; + $sql.= ' SET fk_statut='.self::STATUS_VALIDATED.', facture=0'; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_reopen", LOG_DEBUG); @@ -478,7 +507,7 @@ class Commande extends CommonOrder if (! $error) { - $this->statut = 1; + $this->statut = self::STATUS_VALIDATED; $this->billed = 0; $this->facturee = 0; // deprecated @@ -517,10 +546,10 @@ class Commande extends CommonOrder $now=dol_now(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; - $sql.= ' SET fk_statut = 3,'; + $sql.= ' SET fk_statut = '.self::STATUS_CLOSED.','; $sql.= ' fk_user_cloture = '.$user->id.','; $sql.= " date_cloture = '".$this->db->idate($now)."'"; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; + $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; if ($this->db->query($sql)) { @@ -531,7 +560,7 @@ class Commande extends CommonOrder if (! $error) { - $this->statut=3; + $this->statut=self::STATUS_CLOSED; $this->db->commit(); return 1; @@ -568,9 +597,9 @@ class Commande extends CommonOrder $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; - $sql.= " SET fk_statut = -1"; + $sql.= " SET fk_statut = ".self::STATUS_CANCELED; $sql.= " WHERE rowid = ".$this->id; - $sql.= " AND fk_statut = 1"; + $sql.= " AND fk_statut = ".self::STATUS_VALIDATED; dol_syslog(get_class($this)."::cancel", LOG_DEBUG); if ($this->db->query($sql)) @@ -609,7 +638,7 @@ class Commande extends CommonOrder if (! $error) { - $this->statut=-1; + $this->statut=self::STATUS_CANCELED; $this->db->commit(); return 1; } @@ -933,7 +962,7 @@ class Commande extends CommonOrder } $this->id=0; - $this->statut=0; + $this->statut=self::STATUS_DRAFT; // Clear fields $this->user_author_id = $user->id; @@ -1178,7 +1207,7 @@ class Commande extends CommonOrder // Check parameters if ($type < 0) return -1; - if ($this->statut == 0) + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); @@ -1494,7 +1523,7 @@ class Commande extends CommonOrder $this->lines = array(); - if ($this->statut == 0) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; // Retreive all extrafield for invoice // fetch optionals attributes and labels @@ -1806,7 +1835,7 @@ class Commande extends CommonOrder * * TODO deprecated, move to Shipping class */ - function livraison_array($filtre_statut=-1) + function livraison_array($filtre_statut=self::STATUS_CANCELED) { $delivery = new Livraison($this->db); $deliveryArray = $delivery->livraison_array($filtre_statut); @@ -1821,7 +1850,7 @@ class Commande extends CommonOrder * * TODO FONCTION NON FINIE A FINIR */ - function stock_array($filtre_statut=-1) + function stock_array($filtre_statut=self::STATUS_CANCELED) { $this->stocks = array(); @@ -1863,7 +1892,7 @@ class Commande extends CommonOrder { global $user; - if ($this->statut == 0) + if ($this->statut == self::STATUS_DRAFT) { $this->db->begin(); @@ -1946,7 +1975,7 @@ class Commande extends CommonOrder $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql.= ' SET remise_percent = '.$remise; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; + $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; if ($this->db->query($sql)) { @@ -1980,7 +2009,7 @@ class Commande extends CommonOrder $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql.= ' SET remise_absolue = '.$remise; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = 0 ;'; + $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut = '.self::STATUS_DRAFT.' ;'; dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG); @@ -2012,7 +2041,7 @@ class Commande extends CommonOrder { $sql = "UPDATE ".MAIN_DB_PREFIX."commande"; $sql.= " SET date_commande = ".($date ? $this->db->idate($date) : 'null'); - $sql.= " WHERE rowid = ".$this->id." AND fk_statut = 0"; + $sql.= " WHERE rowid = ".$this->id." AND fk_statut = ".self::STATUS_DRAFT; dol_syslog(get_class($this)."::set_date",LOG_DEBUG); $resql=$this->db->query($sql); @@ -2156,7 +2185,7 @@ class Commande extends CommonOrder $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($draft) $sql.= " AND c.fk_statut = 0"; + if ($draft) $sql.= " AND c.fk_statut = ".self::STATUS_DRAFT; if (is_object($excluser)) $sql.= " AND c.fk_user_author <> ".$excluser->id; $sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->plimit($limit,$offset); @@ -2207,7 +2236,7 @@ class Commande extends CommonOrder function availability($availability_id) { dol_syslog('Commande::availability('.$availability_id.')'); - if ($this->statut >= 0) + if ($this->statut >= self::STATUS_DRAFT) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql .= ' SET fk_availability = '.$availability_id; @@ -2241,7 +2270,7 @@ class Commande extends CommonOrder function demand_reason($demand_reason_id) { dol_syslog('Commande::demand_reason('.$demand_reason_id.')'); - if ($this->statut >= 0) + if ($this->statut >= self::STATUS_DRAFT) { $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande'; $sql .= ' SET fk_input_reason = '.$demand_reason_id; @@ -2312,7 +2341,7 @@ class Commande extends CommonOrder $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'commande SET facture = 1'; - $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > 0'; + $sql.= ' WHERE rowid = '.$this->id.' AND fk_statut > '.self::STATUS_DRAFT; dol_syslog(get_class($this)."::classifyBilled", LOG_DEBUG); if ($this->db->query($sql)) @@ -2790,7 +2819,7 @@ class Commande extends CommonOrder } $sql.= $clause." c.entity = ".$conf->entity; //$sql.= " AND c.fk_statut IN (1,2,3) AND c.facture = 0"; - $sql.= " AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected + $sql.= " AND ((c.fk_statut IN (".self::STATUS_VALIDATED.",".self::STATUS_ACCEPTED.")) OR (c.fk_statut = ".self::STATUS_CLOSED." AND c.facture = 0))"; // If status is 2 and facture=1, it must be selected if ($user->societe_id) $sql.=" AND c.fk_soc = ".$user->societe_id; $resql=$this->db->query($sql); @@ -2864,57 +2893,57 @@ class Commande extends CommonOrder //print 'x'.$statut.'-'.$billed; if ($mode == 0) { - if ($statut==-1) return $langs->trans('StatusOrderCanceled'); - if ($statut==0) return $langs->trans('StatusOrderDraft'); - if ($statut==1) return $langs->trans('StatusOrderValidated'); - if ($statut==2) return $langs->trans('StatusOrderSentShort'); - if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); - if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); + if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceled'); + if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraft'); + if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidated'); + if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort'); + if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBill'); + if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); } elseif ($mode == 1) { - if ($statut==-1) return $langs->trans('StatusOrderCanceledShort'); - if ($statut==0) return $langs->trans('StatusOrderDraftShort'); - if ($statut==1) return $langs->trans('StatusOrderValidatedShort'); - if ($statut==2) return $langs->trans('StatusOrderSentShort'); - if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); - if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); + if ($statut==self::STATUS_CANCELED) return $langs->trans('StatusOrderCanceledShort'); + if ($statut==self::STATUS_DRAFT) return $langs->trans('StatusOrderDraftShort'); + if ($statut==self::STATUS_VALIDATED) return $langs->trans('StatusOrderValidatedShort'); + if ($statut==self::STATUS_ACCEPTED) return $langs->trans('StatusOrderSentShort'); + if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderToBillShort'); + if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return $langs->trans('StatusOrderProcessed'); } elseif ($mode == 2) { - if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort'); - if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort'); - if ($statut==1) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort'); - if ($statut==2) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort'); - if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort'); - if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort'); + if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceledShort'); + if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraftShort'); + if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidatedShort'); + if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSent'),'statut3').' '.$langs->trans('StatusOrderSentShort'); + if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBillShort'); + if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessedShort'); } elseif ($mode == 3) { - if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); - if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); - if ($statut==1) return img_picto($langs->trans('StatusOrderValidated'),'statut1'); - if ($statut==2) return img_picto($langs->trans('StatusOrderSentShort'),'statut3'); - if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7'); - if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6'); + if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5'); + if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0'); + if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1'); + if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort'),'statut3'); + if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7'); + if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6'); } elseif ($mode == 4) { - if ($statut==-1) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled'); - if ($statut==0) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft'); - if ($statut==1) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidated'); - if ($statut==2) return img_picto($langs->trans('StatusOrderSentShort'),'statut3').' '.$langs->trans('StatusOrderSent'); - if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill'); - if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed'); + if ($statut==self::STATUS_CANCELED) return img_picto($langs->trans('StatusOrderCanceled'),'statut5').' '.$langs->trans('StatusOrderCanceled'); + if ($statut==self::STATUS_DRAFT) return img_picto($langs->trans('StatusOrderDraft'),'statut0').' '.$langs->trans('StatusOrderDraft'); + if ($statut==self::STATUS_VALIDATED) return img_picto($langs->trans('StatusOrderValidated'),'statut1').' '.$langs->trans('StatusOrderValidated'); + if ($statut==self::STATUS_ACCEPTED) return img_picto($langs->trans('StatusOrderSentShort'),'statut3').' '.$langs->trans('StatusOrderSent'); + if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderToBill'),'statut7').' '.$langs->trans('StatusOrderToBill'); + if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return img_picto($langs->trans('StatusOrderProcessed'),'statut6').' '.$langs->trans('StatusOrderProcessed'); } elseif ($mode == 5) { - if ($statut==-1) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5'); - if ($statut==0) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0'); - if ($statut==1) return ''.$langs->trans('StatusOrderValidatedShort').' '.img_picto($langs->trans('StatusOrderValidated'),'statut1'); - if ($statut==2) return ''.$langs->trans('StatusOrderSentShort').' '.img_picto($langs->trans('StatusOrderSent'),'statut3'); - if ($statut==3 && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut7'); - if ($statut==3 && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').' '.img_picto($langs->trans('StatusOrderProcessed'),'statut6'); + if ($statut==self::STATUS_CANCELED) return ''.$langs->trans('StatusOrderCanceledShort').' '.img_picto($langs->trans('StatusOrderCanceled'),'statut5'); + if ($statut==self::STATUS_DRAFT) return ''.$langs->trans('StatusOrderDraftShort').' '.img_picto($langs->trans('StatusOrderDraft'),'statut0'); + if ($statut==self::STATUS_VALIDATED) return ''.$langs->trans('StatusOrderValidatedShort').' '.img_picto($langs->trans('StatusOrderValidated'),'statut1'); + if ($statut==self::STATUS_ACCEPTED) return ''.$langs->trans('StatusOrderSentShort').' '.img_picto($langs->trans('StatusOrderSent'),'statut3'); + if ($statut==self::STATUS_CLOSED && (! $billed && empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderToBillShort').' '.img_picto($langs->trans('StatusOrderToBill'),'statut7'); + if ($statut==self::STATUS_CLOSED && ($billed || ! empty($conf->global->WORKFLOW_BILL_ON_SHIPMENT))) return ''.$langs->trans('StatusOrderProcessedShort').' '.img_picto($langs->trans('StatusOrderProcessed'),'statut6'); } } diff --git a/htdocs/compta/bank/ligne.php b/htdocs/compta/bank/ligne.php index ac9fa10ff12..bb1ef29cfa7 100644 --- a/htdocs/compta/bank/ligne.php +++ b/htdocs/compta/bank/ligne.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2014 Laurent Destailleur * Copyright (C) 2004 Christophe Combelles * Copyright (C) 2005-2012 Regis Houssin + * Copyright (C) 2015 Alexandre Spangaro * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -21,7 +22,7 @@ /** * \file htdocs/compta/bank/ligne.php - * \ingroup compta + * \ingroup bank * \brief Page to edit a bank transaction record */ @@ -33,6 +34,8 @@ $langs->load("categories"); $langs->load("compta"); $langs->load("bills"); if (! empty($conf->adherent->enabled)) $langs->load("members"); +if (! empty($conf->don->enabled)) $langs->load("donations"); +if (! empty($conf->loan->enabled)) $langs->load("loan"); $id = (GETPOST('id','int') ? GETPOST('id','int') : GETPOST('account','int')); @@ -345,11 +348,29 @@ if ($result) print $langs->trans("SalaryPayment"); print ''; } + else if ($links[$key]['type']=='payment_loan') { + print ''; + print img_object($langs->trans('ShowLoanPayment'),'payment').' '; + print $langs->trans("PaymentLoan"); + print ''; + } + else if ($links[$key]['type']=='loan') { + print ''; + print img_object($langs->trans('ShowLoan'),'bill').' '; + print $langs->trans("Loan"); + print ''; + } else if ($links[$key]['type']=='member') { print ''; print img_object($langs->trans('ShowMember'),'user').' '; print $links[$key]['label']; print ''; + } + else if ($links[$key]['type']=='payment_donation') { + print ''; + print img_object($langs->trans('ShowDonation'),'payment').' '; + print $langs->trans("DonationPayment"); + print ''; } else if ($links[$key]['type']=='banktransfert') { print ''; diff --git a/htdocs/compta/bank/search.php b/htdocs/compta/bank/search.php index 534a9bb0e95..a1e114430ce 100644 --- a/htdocs/compta/bank/search.php +++ b/htdocs/compta/bank/search.php @@ -30,7 +30,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/bank.lib.php'; require_once DOL_DOCUMENT_ROOT.'/societe/class/societe.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/bankcateg.class.php'; -require_once DOL_DOCUMENT_ROOT . '/core/class/html.formother.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php'; $langs->load("banks"); $langs->load("categories"); @@ -128,7 +128,7 @@ if (! empty($type)) { $sql.= " AND b.fk_type = '".$db->escape($type)."' "; } -//Search period criteria +// Search period criteria if (dol_strlen($search_dt_start)>0) { $sql .= " AND b.dateo >= '" . $db->idate($search_dt_start) . "'"; } diff --git a/htdocs/compta/facture/apercu.php b/htdocs/compta/facture/apercu.php index 8f03e33bb03..340df8172dc 100644 --- a/htdocs/compta/facture/apercu.php +++ b/htdocs/compta/facture/apercu.php @@ -147,16 +147,16 @@ if ($id > 0 || ! empty($ref)) if ($absolute_discount > 0) { print '. '; - if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) + if ($object->statut > Facture::STATUS_DRAFT || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { - if ($object->statut == 0) + if ($object->statut == Facture::STATUS_DRAFT) { print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); print '. '; } else { - if ($object->statut < 1 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) + if ($object->statut < Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); print '
'.$text.'.
'; @@ -181,7 +181,7 @@ if ($id > 0 || ! empty($ref)) { if ($absolute_creditnote > 0) // If not linked will be added later { - if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'
'; + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'
'; else print '.'; } else print '. '; @@ -189,9 +189,9 @@ if ($id > 0 || ! empty($ref)) if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" - if ($object->statut != 1 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) + if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { - if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_DEPOSIT) { $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)); print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse")); @@ -212,7 +212,7 @@ if ($id > 0 || ! empty($ref)) if (! $absolute_discount && ! $absolute_creditnote) { print $langs->trans("CompanyHasNoAbsoluteDiscount"); - if ($object->statut == 0 && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'
'; + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_CREDIT_NOTE && $object->type != Facture::TYPE_DEPOSIT) print ' - '.$addabsolutediscount.'
'; else print '. '; } /*if ($object->statut == 0 && $object->type != 2 && $object->type != 3) diff --git a/htdocs/compta/facture/class/facture-rec.class.php b/htdocs/compta/facture/class/facture-rec.class.php index c87ddb8abfc..a50c1cc91fd 100644 --- a/htdocs/compta/facture/class/facture-rec.class.php +++ b/htdocs/compta/facture/class/facture-rec.class.php @@ -260,7 +260,7 @@ class FactureRec extends Facture $this->rang = $obj->rang; $this->special_code = $obj->special_code; - if ($this->statut == 0) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; /* * Lines diff --git a/htdocs/compta/facture/class/facture.class.php b/htdocs/compta/facture/class/facture.class.php index 9cacb6389ac..358f91bfcf2 100644 --- a/htdocs/compta/facture/class/facture.class.php +++ b/htdocs/compta/facture/class/facture.class.php @@ -95,10 +95,15 @@ class Facture extends CommonInvoice var $note; var $note_private; var $note_public; - //! 0=draft, - //! 1=validated (need to be paid), - //! 2=classified paid partially (close_code='discount_vat','badcustomer') or completely (close_code=null), - //! 3=classified abandoned and no payment done (close_code='badcustomer','abandon' or 'replaced') + + /** + * Check constants for more info: + * - STATUS_DRAFT + * - STATUS_VALIDATED + * - STATUS_PAID + * - STATUS_ABANDONED + * @var int + */ var $statut; //! Fermeture apres paiement partiel: discount_vat, badcustomer, abandon //! Fermeture alors que aucun paiement: replaced (si remplace), abandon @@ -182,6 +187,39 @@ class Facture extends CommonInvoice */ const TYPE_SITUATION = 5; + /** + * Draft + */ + const STATUS_DRAFT = 0; + + /** + * Validated (need to be paid) + */ + const STATUS_VALIDATED = 1; + + /** + * Classified paid. + * If paid partially, $this->close_code can be: + * - CLOSECODE_DISCOUNTVAT + * - CLOSECODE_BADDEBT + * If paid completelly, this->close_code will be null + */ + const STATUS_CLOSED = 2; + + /** + * Classified abandoned and no payment done. + * $this->close_code can be: + * - CLOSECODE_BADDEBT + * - CLOSECODE_ABANDONED + * - CLOSECODE_REPLACED + */ + const STATUS_ABANDONED = 3; + + const CLOSECODE_DISCOUNTVAT = 'discount_vat'; + const CLOSECODE_BADDEBT = 'badcustomer'; + const CLOSECODE_ABANDONED = 'abandon'; + const CLOSECODE_REPLACED = 'replaced'; + /** * Constructor * @@ -680,7 +718,7 @@ class Facture extends CommonInvoice } $this->id=0; - $this->statut=0; + $this->statut= self::STATUS_DRAFT; // Clear fields $this->date = dol_now(); // Date of invoice is set to current date when cloning. // TODO Best is to ask date into confirm box @@ -1005,7 +1043,7 @@ class Facture extends CommonInvoice $this->location_incoterms = $obj->location_incoterms; $this->libelle_incoterms = $obj->libelle_incoterms; - if ($this->statut == 0) $this->brouillon = 1; + if ($this->statut == self::STATUS_DRAFT) $this->brouillon = 1; // Retreive all extrafield for invoice // fetch optionals attributes and labels @@ -1542,7 +1580,7 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::set_paid rowid=".$this->id, LOG_DEBUG); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut=2'; + $sql.= ' fk_statut='.self::STATUS_CLOSED; if (! $close_code) $sql.= ', paye=1'; if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; @@ -1597,7 +1635,7 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= ' SET paye=0, fk_statut=1, close_code=null, close_note=null'; + $sql.= ' SET paye=0, fk_statut='.self::STATUS_VALIDATED.', close_code=null, close_note=null'; $sql.= ' WHERE rowid = '.$this->id; dol_syslog(get_class($this)."::set_unpaid", LOG_DEBUG); @@ -1650,7 +1688,7 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture SET'; - $sql.= ' fk_statut=3'; + $sql.= ' fk_statut='.self::STATUS_ABANDONED; if ($close_code) $sql.= ", close_code='".$this->db->escape($close_code)."'"; if ($close_note) $sql.= ", close_note='".$this->db->escape($close_note)."'"; $sql.= ' WHERE rowid = '.$this->id; @@ -1801,7 +1839,7 @@ class Facture extends CommonInvoice // Validate $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; - $sql.= " SET facnumber='".$num."', fk_statut = 1, fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; + $sql.= " SET facnumber='".$num."', fk_statut = ".self::STATUS_VALIDATED.", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'"; if (! empty($conf->global->FAC_FORCE_DATE_VALIDATION)) // If option enabled, we force invoice date { $sql.= ", datef='".$this->db->idate($this->date)."'"; @@ -1902,7 +1940,7 @@ class Facture extends CommonInvoice { $this->ref = $num; $this->facnumber=$num; - $this->statut=1; + $this->statut= self::STATUS_VALIDATED; $this->brouillon=0; $this->date_validation=$now; $i = 0; @@ -1946,7 +1984,7 @@ class Facture extends CommonInvoice $error=0; - if ($this->statut == 0) + if ($this->statut == self::STATUS_DRAFT) { dol_syslog(get_class($this)."::set_draft already draft status", LOG_WARNING); return 0; @@ -1955,7 +1993,7 @@ class Facture extends CommonInvoice $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."facture"; - $sql.= " SET fk_statut = 0"; + $sql.= " SET fk_statut = ".self::STATUS_DRAFT; $sql.= " WHERE rowid = ".$this->id; dol_syslog(get_class($this)."::set_draft", LOG_DEBUG); @@ -1986,7 +2024,7 @@ class Facture extends CommonInvoice { $old_statut=$this->statut; $this->brouillon = 1; - $this->statut = 0; + $this->statut = self::STATUS_DRAFT; // Call trigger $result=$this->call_trigger('BILL_UNVALIDATE',$user); if ($result < 0) @@ -2478,7 +2516,7 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql.= ' SET remise_percent = '.$remise; $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = 0'; + $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; if ($this->db->query($sql)) { @@ -2513,7 +2551,7 @@ class Facture extends CommonInvoice $sql = 'UPDATE '.MAIN_DB_PREFIX.'facture'; $sql.= ' SET remise_absolue = '.$remise; $sql.= ' WHERE rowid = '.$this->id; - $sql.= ' AND fk_statut = 0'; + $sql.= ' AND fk_statut = '.self::STATUS_DRAFT; dol_syslog(get_class($this)."::set_remise_absolue", LOG_DEBUG); @@ -2813,7 +2851,7 @@ class Facture extends CommonInvoice return $last; } } - else if ($this->statut == 0 && $facref == 'PROV') // Si facture brouillon et provisoire + else if ($this->statut == self::STATUS_DRAFT && $facref == 'PROV') // Si facture brouillon et provisoire { return 1; } @@ -2853,7 +2891,7 @@ class Facture extends CommonInvoice $sql.= " AND s.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; } if ($socid) $sql.= " AND s.rowid = ".$socid; - if ($draft) $sql.= " AND f.fk_statut = 0"; + if ($draft) $sql.= " AND f.fk_statut = ".self::STATUS_DRAFT; if (is_object($excluser)) $sql.= " AND f.fk_user_author <> ".$excluser->id; $sql.= $this->db->order($sortfield,$sortorder); $sql.= $this->db->plimit($limit,$offset); @@ -2914,7 +2952,7 @@ class Facture extends CommonInvoice $sql.= " FROM ".MAIN_DB_PREFIX."facture as f"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON f.rowid = ff.fk_facture_source"; - $sql.= " WHERE (f.fk_statut = 1 OR (f.fk_statut = 3 AND f.close_code = 'abandon'))"; + $sql.= " WHERE (f.fk_statut = ".self::STATUS_VALIDATED." OR (f.fk_statut = ".self::STATUS_ABANDONED." AND f.close_code = '".self::CLOSECODE_ABANDONED."'))"; $sql.= " AND f.entity = ".$conf->entity; $sql.= " AND f.paye = 0"; // Pas classee payee completement $sql.= " AND pf.fk_paiement IS NULL"; // Aucun paiement deja fait @@ -2962,7 +3000,7 @@ class Facture extends CommonInvoice $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."paiement_facture as pf ON f.rowid = pf.fk_facture"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."facture as ff ON (f.rowid = ff.fk_facture_source AND ff.type=".self::TYPE_REPLACEMENT.")"; $sql.= " WHERE f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut in (1,2)"; + $sql.= " AND f.fk_statut in (".self::STATUS_VALIDATED.",".self::STATUS_CLOSED.")"; // $sql.= " WHERE f.fk_statut >= 1"; // $sql.= " AND (f.paye = 1"; // Classee payee completement // $sql.= " OR f.close_code IS NOT NULL)"; // Classee payee partiellement @@ -2978,8 +3016,8 @@ class Facture extends CommonInvoice while ($obj=$this->db->fetch_object($resql)) { $qualified=0; - if ($obj->fk_statut == 1) $qualified=1; - if ($obj->fk_statut == 2) $qualified=1; + if ($obj->fk_statut == self::STATUS_VALIDATED) $qualified=1; + if ($obj->fk_statut == self::STATUS_CLOSED) $qualified=1; if ($qualified) { //$ref=$obj->facnumber; @@ -3010,7 +3048,7 @@ class Facture extends CommonInvoice dol_syslog(get_class($this)."::demande_prelevement", LOG_DEBUG); - if ($this->statut > 0 && $this->paye == 0) + if ($this->statut > self::STATUS_DRAFT && $this->paye == 0) { require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php'; $bac = new CompanyBankAccount($this->db); @@ -3143,7 +3181,7 @@ class Facture extends CommonInvoice } $sql.= $clause." f.paye=0"; $sql.= " AND f.entity = ".$conf->entity; - $sql.= " AND f.fk_statut = 1"; + $sql.= " AND f.fk_statut = ".self::STATUS_VALIDATED; if ($user->societe_id) $sql.= " AND f.fk_soc = ".$user->societe_id; $resql=$this->db->query($sql); diff --git a/htdocs/compta/facture/fiche-rec.php b/htdocs/compta/facture/fiche-rec.php index 1fd4d2c80fc..836b65a2454 100644 --- a/htdocs/compta/facture/fiche-rec.php +++ b/htdocs/compta/facture/fiche-rec.php @@ -523,12 +523,12 @@ else */ print '
'; - if ($object->statut == 0 && $user->rights->facture->creer) + if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->creer) { echo ''; } - if ($object->statut == 0 && $user->rights->facture->supprimer) + if ($object->statut == Facture::STATUS_DRAFT && $user->rights->facture->supprimer) { print ''; } diff --git a/htdocs/compta/facture/impayees.php b/htdocs/compta/facture/impayees.php index ea945940492..d91b52b2166 100644 --- a/htdocs/compta/facture/impayees.php +++ b/htdocs/compta/facture/impayees.php @@ -95,7 +95,7 @@ if ($action == 'presend' && GETPOST('sendmail')) if ($result > 0) // Invoice was found { - if ($object->statut != 1) + if ($object->statut != Facture::STATUS_VALIDATED) { continue; // Payment done or started or canceled } diff --git a/htdocs/compta/facture/prelevement.php b/htdocs/compta/facture/prelevement.php index 1b4f440b461..9d8b9123b68 100644 --- a/htdocs/compta/facture/prelevement.php +++ b/htdocs/compta/facture/prelevement.php @@ -229,15 +229,15 @@ if ($object->id > 0) print '. '; if ($absolute_discount > 0) { - if ($object->statut > 0 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) + if ($object->statut > Facture::STATUS_DRAFT || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { - if ($object->statut == 0) + if ($object->statut == Facture::STATUS_DRAFT) { print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)).'. '; } else { - if ($object->statut < 1 || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) + if ($object->statut < Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_CREDIT_NOTE || $object->type == Facture::TYPE_DEPOSIT) { $text=$langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); print '
'.$text.'.
'; @@ -261,9 +261,9 @@ if ($object->id > 0) if ($absolute_creditnote > 0) { // If validated, we show link "add credit note to payment" - if ($object->statut != 1 || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_CREDIT_NOTE) + if ($object->statut != Facture::STATUS_VALIDATED || $object->type == Facture::TYPE_DEPOSIT || $object->type == Facture::TYPE_CREDIT_NOTE) { - if ($object->statut == 0 && $object->type != Facture::TYPE_DEPOSIT) + if ($object->statut == Facture::STATUS_DRAFT && $object->type != Facture::TYPE_DEPOSIT) { $text=$langs->trans("CompanyHasCreditNote",price($absolute_creditnote),$langs->transnoentities("Currency".$conf->currency)); print $form->textwithpicto($text,$langs->trans("CreditNoteDepositUse")); @@ -350,7 +350,7 @@ if ($object->id > 0) else { print dol_print_date($object->date_lim_reglement,'daytext'); - if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == 1 && ! isset($object->am)) print img_warning($langs->trans('Late')); + if ($object->date_lim_reglement < ($now - $conf->facture->client->warning_delay) && ! $object->paye && $object->statut == Facture::STATUS_VALIDATED && ! isset($object->am)) print img_warning($langs->trans('Late')); } } else @@ -473,7 +473,7 @@ if ($object->id > 0) print "\n
\n"; // Add a withdraw request - if ($object->statut > 0 && $object->paye == 0 && $num == 0) + if ($object->statut > Facture::STATUS_DRAFT && $object->paye == 0 && $num == 0) { if ($user->rights->prelevement->bons->creer) { @@ -488,7 +488,7 @@ if ($object->id > 0) { if ($num == 0) { - if ($object->statut > 0) print ''.$langs->trans("MakeWithdrawRequest").''; + if ($object->statut > Facture::STATUS_DRAFT) print ''.$langs->trans("MakeWithdrawRequest").''; else print ''.$langs->trans("MakeWithdrawRequest").''; } else print ''.$langs->trans("MakeWithdrawRequest").''; diff --git a/htdocs/compta/recap-compta.php b/htdocs/compta/recap-compta.php index 59599e93dc6..0375297316b 100644 --- a/htdocs/compta/recap-compta.php +++ b/htdocs/compta/recap-compta.php @@ -142,7 +142,7 @@ if ($socid > 0) print '
'.$fac->getLibStatut(2,$totalpaye).''.price($fac->total_ttc)." 
@@ -90,7 +97,7 @@
diff --git a/htdocs/don/admin/donation.php b/htdocs/don/admin/donation.php index af00f2dbbcc..bd4683ec3c7 100644 --- a/htdocs/don/admin/donation.php +++ b/htdocs/don/admin/donation.php @@ -31,6 +31,7 @@ require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $langs->load("admin"); $langs->load("donations"); +$langs->load("accountancy"); $langs->load('other'); if (!$user->admin) accessforbidden(); @@ -114,7 +115,25 @@ else if ($action == 'del') } } -// Option +// Options +if ($action == 'set_DONATION_ACCOUNTINGACCOUNT') +{ + $account = GETPOST('DONATION_ACCOUNTINGACCOUNT'); // No alpha here, we want exact string + + $res = dolibarr_set_const($db, "DONATION_ACCOUNTINGACCOUNT",$account,'chaine',0,'',$conf->entity); + + if (! $res > 0) $error++; + + if (! $error) + { + setEventMessage($langs->trans("SetupSaved")); + } + else + { + setEventMessage($langs->trans("Error"),'errors'); + } +} + if ($action == 'set_DONATION_MESSAGE') { $freemessage = GETPOST('DONATION_MESSAGE'); // No alpha here, we want exact string @@ -191,24 +210,42 @@ dol_fiche_head($head, 'general', $langs->trans("Donations"), 0, 'payment'); */ print_titre($langs->trans("Options")); -print ''; -print ''; -print ''; print '
- + textwithpicto('', $langs->trans("ExtrafieldParamHelpselect"),1,0)?> textwithpicto('', $langs->trans("ExtrafieldParamHelpsellist"),1,0)?> textwithpicto('', $langs->trans("ExtrafieldParamHelpchkbxlst"),1,0)?>
'; print ''; -print ''; -print ''; +print ''; +//print ''; print "\n"; $var=true; -$var=! $var; +print ''; +print ''; +print ''; -print ''; + +print ''; +print '\n"; +print ''; + +print ''; +print ''; +print ''; + +$var=! $var; +print '\n"; + print "
'.$langs->trans("Parameters").' '.$langs->trans("Parameters").' 
'; +$var=! $var; +print '
'; +$label = $langs->trans(AccountAccounting); +print ''; +print ''; +print ''; +print ''; +print "
'; print $langs->trans("FreeTextOnDonations").'
'; print ''; print '
'; print ''; print "
\n"; print ''; diff --git a/htdocs/don/class/don.class.php b/htdocs/don/class/don.class.php index ce041351eed..5e36037738f 100644 --- a/htdocs/don/class/don.class.php +++ b/htdocs/don/class/don.class.php @@ -306,7 +306,7 @@ class Don extends CommonObject * @return int <0 if KO, id of created donation if OK * TODO add numbering module for Ref */ - function create($user) + function create($user, $notrigger) { global $conf, $langs; @@ -426,6 +426,7 @@ class Don extends CommonObject * Update a donation record * * @param User $user Objet utilisateur qui met a jour le don + * @param int $notrigger Disable triggers * @return int >0 if OK, <0 if KO */ function update($user, $notrigger=0) @@ -589,11 +590,11 @@ class Don extends CommonObject /** * Load donation from database * - * @param int $rowid Id of donation to load + * @param int $id Id of donation to load * @param string $ref Ref of donation to load * @return int <0 if KO, >0 if OK */ - function fetch($id,$ref='') + function fetch($id, $ref='') { global $conf; @@ -676,7 +677,7 @@ class Don extends CommonObject /** * Validate a promise of donation * - * @param int $rowid id of donation + * @param int $id id of donation * @param int $userid User who validate the promise * @return int <0 if KO, >0 if OK */ @@ -707,7 +708,7 @@ class Don extends CommonObject /** * Classe le don comme paye, le don a ete recu * - * @param int $rowid id du don a modifier + * @param int $id id du don a modifier * @param int $modepaiement mode de paiement * @return int <0 if KO, >0 if OK */ @@ -742,7 +743,7 @@ class Don extends CommonObject /** * Set donation to status canceled * - * @param int $rowid id of donation + * @param int $id id of donation * @return int <0 if KO, >0 if OK */ function set_cancel($id) diff --git a/htdocs/don/payment/card.php b/htdocs/don/payment/card.php index 4c59f566ba5..3abff69a624 100644 --- a/htdocs/don/payment/card.php +++ b/htdocs/don/payment/card.php @@ -33,7 +33,7 @@ $langs->load('banks'); $langs->load('companies'); // Security check -$id=GETPOST("id"); +$id=GETPOST('rowid')?GETPOST('rowid','int'):GETPOST('id','int'); $action=GETPOST("action"); $confirm=GETPOST('confirm'); if ($user->societe_id) $socid=$user->societe_id; @@ -129,7 +129,7 @@ $h++; dol_fiche_head($head, $hselected, $langs->trans("DonationPayment"), 0, 'payment'); /* - * Confirmation de la suppression du paiement + * Confirm deleting of the payment */ if ($action == 'delete') { @@ -138,7 +138,7 @@ if ($action == 'delete') } /* - * Confirmation de la validation du paiement + * Confirm validation of the payment */ if ($action == 'valide') { @@ -192,7 +192,7 @@ print '
'; /* - * List of donations payed + * List of donations paid */ $disable_delete = 0; @@ -262,7 +262,7 @@ print ''; /* - * Boutons Actions + * Actions buttons */ print '
'; diff --git a/htdocs/expedition/shipment.php b/htdocs/expedition/shipment.php index 973066971a3..d29dc513e5c 100644 --- a/htdocs/expedition/shipment.php +++ b/htdocs/expedition/shipment.php @@ -216,7 +216,7 @@ if ($id > 0 || ! empty($ref)) $absolute_creditnote=price2num($absolute_creditnote,'MT'); if ($absolute_discount) { - if ($commande->statut > 0) + if ($commande->statut > Commande::STATUS_DRAFT) { print $langs->trans("CompanyHasAbsoluteDiscount",price($absolute_discount),$langs->transnoentities("Currency".$conf->currency)); } @@ -606,7 +606,7 @@ if ($id > 0 || ! empty($ref)) print '
'; // Bouton expedier sans gestion des stocks - if (empty($conf->stock->enabled) && ($commande->statut > 0 && $commande->statut < 3)) + if (empty($conf->stock->enabled) && ($commande->statut > Commande::STATUS_DRAFT && $commande->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { @@ -626,7 +626,7 @@ if ($id > 0 || ! empty($ref)) // Bouton expedier avec gestion des stocks - if (! empty($conf->stock->enabled) && ($commande->statut > 0 && $commande->statut < 3)) + if (! empty($conf->stock->enabled) && ($commande->statut > Commande::STATUS_DRAFT && $commande->statut < Commande::STATUS_CLOSED)) { if ($user->rights->expedition->creer) { diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang index 21b008b1d0e..e7341e98fe7 100755 --- a/htdocs/langs/en_US/admin.lang +++ b/htdocs/langs/en_US/admin.lang @@ -389,6 +389,7 @@ ExtrafieldSeparator=Separator ExtrafieldCheckBox=Checkbox ExtrafieldRadio=Radio button ExtrafieldCheckBoxFromList= Checkbox from table +ExtrafieldLink=Link to an object ExtrafieldParamHelpselect=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
...

In order to have the list depending on another :
1,value1|parent_list_code:parent_key
2,value2|parent_list_code:parent_key ExtrafieldParamHelpcheckbox=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... ExtrafieldParamHelpradio=Parameters list have to be like key,value

for example :
1,value1
2,value2
3,value3
... diff --git a/htdocs/langs/en_US/loan.lang b/htdocs/langs/en_US/loan.lang index 4aba2de625c..e082f166959 100644 --- a/htdocs/langs/en_US/loan.lang +++ b/htdocs/langs/en_US/loan.lang @@ -4,6 +4,7 @@ Loans=Loans NewLoan=New Loan ShowLoan=Show Loan PaymentLoan=Loan payment +ShowLoanPayment=Show Loan Payment Capital=Capital Insurance=Insurance Interest=Interest diff --git a/htdocs/langs/en_US/suppliers.lang b/htdocs/langs/en_US/suppliers.lang index 53b0618c7b1..441eba9d884 100644 --- a/htdocs/langs/en_US/suppliers.lang +++ b/htdocs/langs/en_US/suppliers.lang @@ -42,4 +42,5 @@ SentToSuppliers=Sent to suppliers ListOfSupplierOrders=List of supplier orders MenuOrdersSupplierToBill=Supplier orders to invoice NbDaysToDelivery=Delivery delay in days -DescNbDaysToDelivery=The biggest delay is display among order product list \ No newline at end of file +DescNbDaysToDelivery=The biggest delay is display among order product list +UseDoubleApproval=Use double approval (the second approval will be any user of a defined user group) \ No newline at end of file diff --git a/htdocs/langs/fr_FR/donations.lang b/htdocs/langs/fr_FR/donations.lang index 84081b64576..fab53285a7c 100644 --- a/htdocs/langs/fr_FR/donations.lang +++ b/htdocs/langs/fr_FR/donations.lang @@ -32,7 +32,7 @@ ThankYou=Merci IConfirmDonationReception=Le bénéficiaire reconnait avoir reçu au titre des versements ouvrant droit à réduction d'impôt, la somme de MinimumAmount=Don minimum de %s FreeTextOnDonations=Mention complémentaire sur les dons -FrenchOptions=Options propre à la france +FrenchOptions=Options propres à la france DONATION_ART200=Afficher article 200 du CGI si vous êtes concernés DONATION_ART238=Afficher article 238 du CGI si vous êtes concernés DONATION_ART885=Afficher article 885 du CGI si vous êtes concernés diff --git a/htdocs/langs/fr_FR/trips.lang b/htdocs/langs/fr_FR/trips.lang index 3a11b7c4036..2170c579547 100644 --- a/htdocs/langs/fr_FR/trips.lang +++ b/htdocs/langs/fr_FR/trips.lang @@ -22,7 +22,7 @@ SearchATripAndExpense=Rechercher une note de frais ClassifyRefunded=Classer 'Remboursé' ExpenseReportWaitingForApproval=Une nouvelle note de frais a été soumise pour approbation ExpenseReportWaitingForApprovalMessage=A new expense report has been submitted and is waiting for approval.\n- User: %s\n- Period: %s\nClick here to validate: %s -TripId=Id expense report +TripId=Id note de frais AnyOtherInThisListCanValidate=Person to inform for validation. TripSociete=Information société TripSalarie=Informations utilisateur diff --git a/htdocs/loan/class/paymentloan.class.php b/htdocs/loan/class/paymentloan.class.php index 5c24621d802..51961e37e6e 100644 --- a/htdocs/loan/class/paymentloan.class.php +++ b/htdocs/loan/class/paymentloan.class.php @@ -391,7 +391,7 @@ class PaymentLoan extends CommonObject * @param string $emetteur_banque Name of bank * @return int <0 if KO, >0 if OK */ - function addPaymentToBank($user,$mode,$label,$accountid,$emetteur_nom,$emetteur_banque) + function addPaymentToBank($user, $mode, $label, $accountid, $emetteur_nom, $emetteur_banque) { global $conf; @@ -448,7 +448,7 @@ class PaymentLoan extends CommonObject //$linkaddedforthirdparty=array(); if ($mode == 'payment_loan') { - $result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/loan/card.php?id=', $this->type_libelle.(($this->label && $this->label!=$this->type_libelle)?' ('.$this->label.')':''),'loan'); + $result=$acc->add_url_line($bank_line_id, $this->id, DOL_URL_ROOT.'/loan/card.php?id=', ($this->label?$this->label:''),'loan'); if ($result <= 0) dol_print_error($this->db); } } diff --git a/htdocs/loan/payment/payment.php b/htdocs/loan/payment/payment.php index ece4a5e0271..32e6ed57d2d 100644 --- a/htdocs/loan/payment/payment.php +++ b/htdocs/loan/payment/payment.php @@ -41,6 +41,9 @@ if ($user->societe_id > 0) $socid = $user->societe_id; } +$loan = new Loan($db); +$loan->fetch($chid); + /* * Actions */ @@ -92,6 +95,7 @@ if ($action == 'add_payment') $payment = new PaymentLoan($db); $payment->chid = $chid; $payment->datepaid = $datepaid; + $payment->label = $loan->label; $payment->amount_capital = GETPOST('amount_capital'); $payment->amount_insurance = GETPOST('amount_insurance'); $payment->amount_interest = GETPOST('amount_interest'); @@ -150,10 +154,6 @@ $form=new Form($db); // Form to create loan's payment if ($_GET["action"] == 'create') { - - $loan = new Loan($db); - $loan->fetch($chid); - $total = $loan->capital; print_fiche_titre($langs->trans("DoPayment")); diff --git a/htdocs/margin/tabs/productMargins.php b/htdocs/margin/tabs/productMargins.php index d811f898c0b..2123f683c21 100644 --- a/htdocs/margin/tabs/productMargins.php +++ b/htdocs/margin/tabs/productMargins.php @@ -79,7 +79,7 @@ if ($id > 0 || ! empty($ref)) { $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==1?'service':'product'); + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'margin', $titre, 0, $picto); print ''; diff --git a/htdocs/product/canvas/product/actions_card_product.class.php b/htdocs/product/canvas/product/actions_card_product.class.php index 3537dc288a9..84140ee3f6a 100644 --- a/htdocs/product/canvas/product/actions_card_product.class.php +++ b/htdocs/product/canvas/product/actions_card_product.class.php @@ -143,7 +143,7 @@ class ActionsCardProduct $this->tpl['showrefnav'] = $form->showrefnav($this->object,'ref','',1,'ref'); $titre=$langs->trans("CardProduct".$this->object->type); - $picto=($this->object->type==1?'service':'product'); + $picto=($this->object->type==Product::TYPE_SERVICE?'service':'product'); $this->tpl['showhead']=dol_get_fiche_head($head, 'card', $titre, 0, $picto); $this->tpl['showend']=dol_get_fiche_end(); diff --git a/htdocs/product/canvas/service/actions_card_service.class.php b/htdocs/product/canvas/service/actions_card_service.class.php index cbb9e10750c..b36e7b317c6 100644 --- a/htdocs/product/canvas/service/actions_card_service.class.php +++ b/htdocs/product/canvas/service/actions_card_service.class.php @@ -142,7 +142,7 @@ class ActionsCardService $this->tpl['showrefnav'] = $form->showrefnav($this->object,'ref','',1,'ref'); $titre=$langs->trans("CardProduct".$this->object->type); - $picto=($this->object->type==1?'service':'product'); + $picto=($this->object->type==Product::TYPE_SERVICE?'service':'product'); $this->tpl['showhead']=dol_get_fiche_head($head, 'card', $titre, 0, $picto); $this->tpl['showend']=dol_get_fiche_end(); diff --git a/htdocs/product/card.php b/htdocs/product/card.php index 0a74845a763..eecec0705f7 100644 --- a/htdocs/product/card.php +++ b/htdocs/product/card.php @@ -461,7 +461,7 @@ if (empty($reshook)) if ($action == 'confirm_delete' && $confirm != 'yes') { $action=''; } if ($action == 'confirm_delete' && $confirm == 'yes') { - if (($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer)) + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) { $result = $object->delete($object->id); } @@ -768,8 +768,8 @@ if (GETPOST("cancel") == $langs->trans("Cancel")) */ $helpurl=''; -if (GETPOST("type") == '0' || ($object->type == '0')) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; -if (GETPOST("type") == '1' || ($object->type == '1')) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; +if (GETPOST("type") == '0' || ($object->type == Product::TYPE_PRODUCT)) $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; +if (GETPOST("type") == '1' || ($object->type == Product::TYPE_SERVICE)) $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; if (isset($_GET['type'])) $title = $langs->trans('CardProduct'.GETPOST('type')); else $title = $langs->trans('ProductServiceCard'); @@ -1193,7 +1193,7 @@ else }*/ // Nature - if($object->type!=1) + if($object->type!= Product::TYPE_SERVICE) { print ''; // Nature - if($object->type!=1) + if($object->type!= Product::TYPE_SERVICE) { print ''; // Nature - if($object->type!=1) + if($object->type!=Product::TYPE_SERVICE) { print '
'.$langs->trans("Nature").''; $statutarray=array('-1'=>' ', '1' => $langs->trans("Finished"), '0' => $langs->trans("RowMaterial")); @@ -1308,7 +1308,7 @@ else { $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==1?'service':'product'); + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'card', $titre, 0, $picto); $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); @@ -1331,7 +1331,7 @@ else $nblignes=7; if (! empty($conf->produit->enabled) && ! empty($conf->service->enabled)) $nblignes++; if ($showbarcode) $nblignes+=2; - if ($object->type!=1) $nblignes++; + if ($object->type!= Product::TYPE_SERVICE) $nblignes++; if (empty($conf->global->PRODUCT_DISABLE_CUSTOM_INFO)) $nblignes+=2; if ($object->isservice()) $nblignes++; else $nblignes+=4; @@ -1464,7 +1464,7 @@ else print '
'.$langs->trans("Nature").''; print $object->getLibFinished(); @@ -1628,8 +1628,8 @@ if (empty($reshook)) } $object_is_used = $object->isObjectUsed($object->id); - if (($object->type == 0 && $user->rights->produit->supprimer) - || ($object->type == 1 && $user->rights->service->supprimer)) + if (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->supprimer) + || ($object->type == Product::TYPE_SERVICE && $user->rights->service->supprimer)) { if (empty($object_is_used) && (! isset($object->no_button_delete) || $object->no_button_delete <> 1)) { diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index d08ed699b7f..8c811a57a1a 100755 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -61,8 +61,12 @@ class Product extends CommonObject var $libelle; // TODO deprecated var $label; var $description; - //! Type 0 for regular product, 1 for service (Advanced feature: 2 for assembly kit, 3 for stock kit) - var $type; + + /** + * Check TYPE constants + * @var int + */ + var $type = self::TYPE_PRODUCT; //! Selling price var $price; // Price net var $price_ttc; // Price with tax @@ -171,6 +175,23 @@ class Product extends CommonObject var $fk_price_expression; + /** + * Regular product + */ + const TYPE_PRODUCT = 0; + /** + * Service + */ + const TYPE_SERVICE = 1; + /** + * Advanced feature: assembly kit + */ + const TYPE_ASSEMBLYKIT = 2; + /** + * Advanced feature: stock kit + */ + const TYPE_STOCKKIT = 3; + /** * Constructor * @@ -233,7 +254,6 @@ class Product extends CommonObject // Clean parameters $this->ref = dol_string_nospecial(trim($this->ref)); $this->libelle = trim($this->libelle); - if (empty($this->type)) $this->type=0; $this->price_ttc=price2num($this->price_ttc); $this->price=price2num($this->price); $this->price_min_ttc=price2num($this->price_min_ttc); @@ -795,7 +815,7 @@ class Product extends CommonObject $this->error = "Object must be fetched before calling delete"; return -1; } - if (($this->type == 0 && empty($user->rights->produit->supprimer)) || ($this->type == 1 && empty($user->rights->service->supprimer))) + if (($this->type == Product::TYPE_PRODUCT && empty($user->rights->produit->supprimer)) || ($this->type == Product::TYPE_SERVICE && empty($user->rights->service->supprimer))) { $this->error = "ErrorForbidden"; return 0; @@ -2932,8 +2952,8 @@ class Product extends CommonObject $result=''; $newref=$this->ref; if ($maxlength) $newref=dol_trunc($newref,$maxlength,'middle'); - if ($this->type == 0) $label = '' . $langs->trans("ShowProduct") . ''; - if ($this->type == 1) $label = '' . $langs->trans("ShowService") . ''; + if ($this->type == Product::TYPE_PRODUCT) $label = '' . $langs->trans("ShowProduct") . ''; + if ($this->type == Product::TYPE_SERVICE) $label = '' . $langs->trans("ShowService") . ''; if (! empty($this->ref)) $label .= '
' . $langs->trans('ProductRef') . ': ' . $this->ref; if (! empty($this->label)) @@ -2968,8 +2988,8 @@ class Product extends CommonObject } if ($withpicto) { - if ($this->type == 0) $result.=($link.img_object($langs->trans("ShowProduct").' '.$this->label, 'product', 'class="classfortooltip"').$linkend.' '); - if ($this->type == 1) $result.=($link.img_object($langs->trans("ShowService").' '.$this->label, 'service', 'class="classfortooltip"').$linkend.' '); + if ($this->type == Product::TYPE_PRODUCT) $result.=($link.img_object($langs->trans("ShowProduct").' '.$this->label, 'product', 'class="classfortooltip"').$linkend.' '); + if ($this->type == Product::TYPE_SERVICE) $result.=($link.img_object($langs->trans("ShowService").' '.$this->label, 'service', 'class="classfortooltip"').$linkend.' '); } $result.=$link.$newref.$linkend; return $result; @@ -3666,7 +3686,7 @@ class Product extends CommonObject */ function isproduct() { - return ($this->type != 1 ? true : false); + return ($this->type != Product::TYPE_PRODUCT ? true : false); } /** @@ -3676,7 +3696,7 @@ class Product extends CommonObject */ function isservice() { - return ($this->type == 1 ? true : false); + return ($this->type == Product::TYPE_SERVICE ? true : false); } /** @@ -3733,7 +3753,6 @@ class Product extends CommonObject $this->tosell=1; $this->tobuy=1; $this->tobatch=0; - $this->type=0; $this->note='This is a comment (private)'; $this->barcode=-1; // Create barcode automatically diff --git a/htdocs/product/composition/card.php b/htdocs/product/composition/card.php index 53f79266c25..96f2a589429 100644 --- a/htdocs/product/composition/card.php +++ b/htdocs/product/composition/card.php @@ -176,7 +176,7 @@ llxHeader("","",$langs->trans("CardProduct".$object->type)); $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); -$picto=($object->type==1?'service':'product'); +$picto=($object->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'subproduct', $titre, 0, $picto); @@ -207,7 +207,7 @@ if ($id > 0 || ! empty($ref)) print '
'.$langs->trans("Nature").''; print $object->getLibFinished(); @@ -474,7 +474,7 @@ if ($id > 0 || ! empty($ref)) // check if a product is not already a parent product of this one $prod_arbo=new Product($db); $prod_arbo->id=$objp->rowid; - if ($prod_arbo->type==2 || $prod_arbo->type==3) + if ($prod_arbo->type==Product::TYPE_ASSEMBLYKIT || $prod_arbo->type== Product::TYPE_STOCKKIT) { $is_pere=0; $prod_arbo->get_sousproduits_arbo(); diff --git a/htdocs/product/document.php b/htdocs/product/document.php index e46dc0384b2..9a71eac4f55 100644 --- a/htdocs/product/document.php +++ b/htdocs/product/document.php @@ -102,7 +102,7 @@ if ($object->id) { $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==1?'service':'product'); + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'documents', $titre, 0, $picto); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$object,$action); // Note that $action and $object may have been modified by hook @@ -146,7 +146,7 @@ if ($object->id) print ''; $modulepart = 'produit'; - $permission = (($object->type == 0 && $user->rights->produit->creer) || ($object->type == 1 && $user->rights->service->creer)); + $permission = (($object->type == Product::TYPE_PRODUCT && $user->rights->produit->creer) || ($object->type == Product::TYPE_SERVICE && $user->rights->service->creer)); $param = '&id=' . $object->id; include_once DOL_DOCUMENT_ROOT . '/core/tpl/document_actions_post_headers.tpl.php'; } diff --git a/htdocs/product/fournisseurs.php b/htdocs/product/fournisseurs.php index b360829a341..c2196aba00b 100644 --- a/htdocs/product/fournisseurs.php +++ b/htdocs/product/fournisseurs.php @@ -259,7 +259,7 @@ if ($id || $ref) $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); + $picto=($product->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'suppliers', $titre, 0, $picto); diff --git a/htdocs/product/photos.php b/htdocs/product/photos.php index 0ae65a7dec6..8a6e2ddbd6b 100644 --- a/htdocs/product/photos.php +++ b/htdocs/product/photos.php @@ -102,7 +102,7 @@ if ($object->id) */ $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==1?'service':'product'); + $picto=($object->type== Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'photos', $titre, 0, $picto); /* @@ -145,8 +145,8 @@ if ($object->id) $permtoedit=0; - if ($user->rights->produit->creer && $object->type == 0) $permtoedit=1; - if ($user->rights->service->creer && $object->type == 1) $permtoedit=1; + if ($user->rights->produit->creer && $object->type == Product::TYPE_PRODUCT) $permtoedit=1; + if ($user->rights->service->creer && $object->type == Product::TYPE_SERVICE) $permtoedit=1; if (empty($conf->global->MAIN_UPLOAD_DOC)) $permtoedit=0; /* ************************************************************************** */ diff --git a/htdocs/product/price.php b/htdocs/product/price.php index f6cd6187e85..da61ccc45b8 100644 --- a/htdocs/product/price.php +++ b/htdocs/product/price.php @@ -347,7 +347,7 @@ llxHeader("", "", $langs->trans("CardProduct" . $object->type)); $head = product_prepare_head($object, $user); $titre = $langs->trans("CardProduct" . $object->type); -$picto = ($object->type == 1 ? 'service' : 'product'); +$picto = ($object->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'price', $titre, 0, $picto); print ''; diff --git a/htdocs/product/stats/card.php b/htdocs/product/stats/card.php index 9600e6c0a44..788068ea5ec 100644 --- a/htdocs/product/stats/card.php +++ b/htdocs/product/stats/card.php @@ -69,7 +69,7 @@ if (! empty($id) || ! empty($ref)) { $head=product_prepare_head($object, $user); $titre=$langs->trans("CardProduct".$object->type); - $picto=($object->type==1?'service':'product'); + $picto=($object->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'stats', $titre, 0, $picto); diff --git a/htdocs/product/stats/commande.php b/htdocs/product/stats/commande.php index 49a443938ab..a1e538f4559 100644 --- a/htdocs/product/stats/commande.php +++ b/htdocs/product/stats/commande.php @@ -91,7 +91,7 @@ if ($id > 0 || ! empty($ref)) { $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); + $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stats/commande_fournisseur.php b/htdocs/product/stats/commande_fournisseur.php index 8cbdea41495..1b324d99bbf 100644 --- a/htdocs/product/stats/commande_fournisseur.php +++ b/htdocs/product/stats/commande_fournisseur.php @@ -98,7 +98,7 @@ if ($id > 0 || ! empty($ref)) { if ($result > 0) { $head = product_prepare_head($product, $user); $titre = $langs->trans("CardProduct" . $product->type); - $picto = ($product->type == 1 ? 'service' : 'product'); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stats/contrat.php b/htdocs/product/stats/contrat.php index 189ead2eaa2..aa535f02575 100644 --- a/htdocs/product/stats/contrat.php +++ b/htdocs/product/stats/contrat.php @@ -81,7 +81,7 @@ if ($id > 0 || ! empty($ref)) { $head=product_prepare_head($product,$user); $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); + $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stats/facture.php b/htdocs/product/stats/facture.php index 2ae8164b0f9..c0fa1481269 100644 --- a/htdocs/product/stats/facture.php +++ b/htdocs/product/stats/facture.php @@ -92,7 +92,7 @@ if ($id > 0 || ! empty($ref)) { $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); + $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); $reshook=$hookmanager->executeHooks('formObjectOptions',$parameters,$product,$action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stats/facture_fournisseur.php b/htdocs/product/stats/facture_fournisseur.php index 2e8e84621ba..275a2ff8604 100644 --- a/htdocs/product/stats/facture_fournisseur.php +++ b/htdocs/product/stats/facture_fournisseur.php @@ -93,7 +93,7 @@ if ($id > 0 || ! empty($ref)) { $head = product_prepare_head($product, $user); $titre = $langs->trans("CardProduct" . $product->type); - $picto = ($product->type == 1 ? 'service' : 'product'); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stats/propal.php b/htdocs/product/stats/propal.php index 10fd8247204..4eae4c238e1 100644 --- a/htdocs/product/stats/propal.php +++ b/htdocs/product/stats/propal.php @@ -91,7 +91,7 @@ if ($id > 0 || ! empty($ref)) { $head = product_prepare_head($product, $user); $titre = $langs->trans("CardProduct" . $product->type); - $picto = ($product->type == 1 ? 'service' : 'product'); + $picto = ($product->type == Product::TYPE_SERVICE ? 'service' : 'product'); dol_fiche_head($head, 'referers', $titre, 0, $picto); $reshook = $hookmanager->executeHooks('formObjectOptions', $parameters, $product, $action); // Note that $action and $object may have been modified by hook diff --git a/htdocs/product/stock/class/mouvementstock.class.php b/htdocs/product/stock/class/mouvementstock.class.php index 1994b4ad6c2..c41fe590d18 100644 --- a/htdocs/product/stock/class/mouvementstock.class.php +++ b/htdocs/product/stock/class/mouvementstock.class.php @@ -117,7 +117,7 @@ class MouvementStock extends CommonObject // Define if we must make the stock change (If product type is a service or if stock is used also for services) $movestock=0; - if ($product->type != 1 || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1; + if ($product->type != Product::TYPE_SERVICE || ! empty($conf->global->STOCK_SUPPORTS_SERVICES)) $movestock=1; if ($movestock && $entrepot_id > 0) // Change stock for current product, change for subproduct is done after { diff --git a/htdocs/product/stock/product.php b/htdocs/product/stock/product.php index 044da6c9aa4..116fff88809 100644 --- a/htdocs/product/stock/product.php +++ b/htdocs/product/stock/product.php @@ -7,6 +7,7 @@ * Copyright (C) 2013 Cédric Salvador * Copyright (C) 2013 Juanjo Menent * Copyright (C) 2014-2015 Cédric Gross + * Copyright (C) 2015 Marcos García * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -385,7 +386,7 @@ if ($id > 0 || $ref) { $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); - $picto=($product->type==1?'service':'product'); + $picto=($product->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'stock', $titre, 0, $picto); dol_htmloutput_events(); diff --git a/htdocs/product/traduction.php b/htdocs/product/traduction.php index 34b38fe8919..480f739285d 100644 --- a/htdocs/product/traduction.php +++ b/htdocs/product/traduction.php @@ -170,7 +170,7 @@ $formadmin=new FormAdmin($db); $head=product_prepare_head($product, $user); $titre=$langs->trans("CardProduct".$product->type); -$picto=($product->type==1?'service':'product'); +$picto=($product->type==Product::TYPE_SERVICE?'service':'product'); dol_fiche_head($head, 'translation', $titre, 0, $picto); print '
'; diff --git a/htdocs/societe/class/societe.class.php b/htdocs/societe/class/societe.class.php index c3d86f4fae3..2df9ba0776f 100644 --- a/htdocs/societe/class/societe.class.php +++ b/htdocs/societe/class/societe.class.php @@ -241,7 +241,6 @@ class Societe extends CommonObject var $specimen; - /** * 0=no customer, 1=customer, 2=prospect, 3=customer and prospect * @var int diff --git a/htdocs/webservices/server_invoice.php b/htdocs/webservices/server_invoice.php index 9c5bd24b463..3c1a122fa6f 100644 --- a/htdocs/webservices/server_invoice.php +++ b/htdocs/webservices/server_invoice.php @@ -522,7 +522,7 @@ function createInvoice($authentication,$invoice) $newobject->date=dol_stringtotime($invoice['date'],'dayrfc'); $newobject->note_private=$invoice['note_private']; $newobject->note_public=$invoice['note_public']; - $newobject->statut=0; // We start with status draft + $newobject->statut= Facture::STATUS_DRAFT; // We start with status draft $newobject->fk_project=$invoice['project_id']; $newobject->date_creation=$now; diff --git a/htdocs/webservices/server_order.php b/htdocs/webservices/server_order.php index f089a86aeb6..2f5955d8ec1 100644 --- a/htdocs/webservices/server_order.php +++ b/htdocs/webservices/server_order.php @@ -687,7 +687,7 @@ function createOrder($authentication,$order) $newobject->date_lim_reglement=dol_stringtotime($order['date_due'],'dayrfc'); $newobject->note_private=$order['note_private']; $newobject->note_public=$order['note_public']; - $newobject->statut=0; // We start with status draft + $newobject->statut=Commande::STATUS_DRAFT; // We start with status draft $newobject->billed=$order['billed']; $newobject->fk_project=$order['project_id']; $newobject->fk_delivery_address=$order['fk_delivery_address'];