From 6149994b4308455a9dbfb6daf6657c40eab3230e Mon Sep 17 00:00:00 2001 From: jean Date: Wed, 24 Sep 2014 22:05:53 +0200 Subject: [PATCH 1/4] Adding hook 'suppliercard' on supplier cartd --- htdocs/fourn/card.php | 112 +++++++++++++++++++++++------------------- 1 file changed, 61 insertions(+), 51 deletions(-) diff --git a/htdocs/fourn/card.php b/htdocs/fourn/card.php index 313f82547e7..07ede4329b6 100644 --- a/htdocs/fourn/card.php +++ b/htdocs/fourn/card.php @@ -4,6 +4,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur * Copyright (C) 2005-2010 Regis Houssin * Copyright (C) 2010-2014 Juanjo Menent + * Copyright (C) 2014 Jean Heimburger * * 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 @@ -48,6 +49,9 @@ $result = restrictedArea($user, 'societe&fournisseur', $id, '&societe'); $object = new Fournisseur($db); +// Initialize technical object to manage hooks of thirdparties. Note that conf->hooks_modules contains array array +$hookmanager->initHooks(array('suppliercard')); + /* * Action */ @@ -425,60 +429,66 @@ if ($object->fetch($id)) /* * Barre d'actions */ + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) + { - print '
'; + print '
'; - if ($user->rights->fournisseur->commande->creer) - { - $langs->load("orders"); - print ''.$langs->trans("AddOrder").''; + if ($user->rights->fournisseur->commande->creer) + { + $langs->load("orders"); + print ''.$langs->trans("AddOrder").''; + } + + if ($user->rights->fournisseur->facture->creer) + { + $langs->load("bills"); + print ''.$langs->trans("AddBill").''; + } + + // Add action + if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + if ($user->rights->agenda->myactions->create) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } + } + + print '
'; + print '
'; + + if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) + { + print '
'; + // List of contacts + show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + // Addresses list + if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) + { + $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); + } + + if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) + { + print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); + + // List of todo actions + show_actions_todo($conf,$langs,$db,$object); + + // List of done actions + show_actions_done($conf,$langs,$db,$object); + } } - - if ($user->rights->fournisseur->facture->creer) - { - $langs->load("bills"); - print ''.$langs->trans("AddBill").''; - } - - // Add action - if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - if ($user->rights->agenda->myactions->create) - { - print ''.$langs->trans("AddAction").''; - } - else - { - print ''.$langs->trans("AddAction").''; - } - } - - print '
'; - print '
'; - - if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB)) - { - print '
'; - // List of contacts - show_contacts($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } - - // Addresses list - if (! empty($conf->global->SOCIETE_ADDRESSES_MANAGEMENT) && ! empty($conf->global->MAIN_REPEATADDRESSONEACHTAB)) - { - $result=show_addresses($conf,$langs,$db,$object,$_SERVER["PHP_SELF"].'?socid='.$object->id); - } - - if (! empty($conf->global->MAIN_REPEATTASKONEACHTAB)) - { - print load_fiche_titre($langs->trans("ActionsOnCompany"),'',''); - - // List of todo actions - show_actions_todo($conf,$langs,$db,$object); - - // List of done actions - show_actions_done($conf,$langs,$db,$object); - } } else { From e9374e8c08c46b1504d012bf4ffdff5a5995187f Mon Sep 17 00:00:00 2001 From: jean Date: Thu, 25 Sep 2014 09:26:32 +0200 Subject: [PATCH 2/4] adding hook for addMoreActionsbuttons --- htdocs/fourn/commande/card.php | 152 +++++++++++++++++---------------- 1 file changed, 79 insertions(+), 73 deletions(-) diff --git a/htdocs/fourn/commande/card.php b/htdocs/fourn/commande/card.php index ba3cb7e9de0..d0fa34d87ad 100644 --- a/htdocs/fourn/commande/card.php +++ b/htdocs/fourn/commande/card.php @@ -1814,98 +1814,104 @@ elseif (! empty($object->id)) /** * Boutons actions */ - if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete') + $parameters = array(); + $reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been + // modified by hook + if (empty($reshook)) { - print '
'; - - // Validate - if ($object->statut == 0 && $num > 0) + if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete') { - if ($user->rights->fournisseur->commande->valider) + print '
'; + + // Validate + if ($object->statut == 0 && $num > 0) { - print ''.$langs->trans('Validate').''; + if ($user->rights->fournisseur->commande->valider) + { + print ''.$langs->trans('Validate').''; + } } - } - - // Modify - if ($object->statut == 1) - { - if ($user->rights->fournisseur->commande->commander) + + // Modify + if ($object->statut == 1) { - print ''.$langs->trans("Modify").''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("Modify").''; + } } - } - - // Approve - if ($object->statut == 1) - { - if ($user->rights->fournisseur->commande->approuver) + + // Approve + if ($object->statut == 1) { - print ''.$langs->trans("ApproveOrder").''; - print ''.$langs->trans("RefuseOrder").''; + if ($user->rights->fournisseur->commande->approuver) + { + print ''.$langs->trans("ApproveOrder").''; + print ''.$langs->trans("RefuseOrder").''; + } + else + { + print ''.$langs->trans("ApproveOrder").''; + print ''.$langs->trans("RefuseOrder").''; + } } - else + + // Send + if (in_array($object->statut, array(2, 3, 4, 5))) { - print ''.$langs->trans("ApproveOrder").''; - print ''.$langs->trans("RefuseOrder").''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans('SendByMail').''; + } } - } - - // Send - if (in_array($object->statut, array(2, 3, 4, 5))) - { - if ($user->rights->fournisseur->commande->commander) + + // Reopen + if (in_array($object->statut, array(2, 5, 6, 7, 9))) { - print ''.$langs->trans('SendByMail').''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("ReOpen").''; + } } - } - - // Reopen - if (in_array($object->statut, array(2, 5, 6, 7, 9))) - { - if ($user->rights->fournisseur->commande->commander) + + // Create bill + if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted { - print ''.$langs->trans("ReOpen").''; + if ($user->rights->fournisseur->facture->creer) + { + print ''.$langs->trans("CreateBill").''; + } + + //if ($user->rights->fournisseur->commande->creer && $object->statut > 2) + //{ + // print ''.$langs->trans("ClassifyBilled").''; + //} } - } - - // Create bill - if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted - { - if ($user->rights->fournisseur->facture->creer) + + // Cancel + if ($object->statut == 2) { - print ''.$langs->trans("CreateBill").''; + if ($user->rights->fournisseur->commande->commander) + { + print ''.$langs->trans("CancelOrder").''; + } } - - //if ($user->rights->fournisseur->commande->creer && $object->statut > 2) - //{ - // print ''.$langs->trans("ClassifyBilled").''; - //} - } - - // Cancel - if ($object->statut == 2) - { - if ($user->rights->fournisseur->commande->commander) + + // Clone + if ($user->rights->fournisseur->commande->creer) { - print ''.$langs->trans("CancelOrder").''; + print ''.$langs->trans("ToClone").''; } + + // Delete + if ($user->rights->fournisseur->commande->supprimer) + { + print ''.$langs->trans("Delete").''; + } + + print "
"; } - - // Clone - if ($user->rights->fournisseur->commande->creer) - { - print ''.$langs->trans("ToClone").''; - } - - // Delete - if ($user->rights->fournisseur->commande->supprimer) - { - print ''.$langs->trans("Delete").''; - } - - print "
"; } print "
"; From 82a2bb16904b08bedbac160bba136e19c8d65eea Mon Sep 17 00:00:00 2001 From: jean Date: Thu, 25 Sep 2014 17:00:44 +0200 Subject: [PATCH 3/4] list bof orders to process : status validated or in process, or closed but not billed --- htdocs/commande/list.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/commande/list.php b/htdocs/commande/list.php index d699192acbf..d285a241b46 100644 --- a/htdocs/commande/list.php +++ b/htdocs/commande/list.php @@ -155,8 +155,9 @@ if ($viewstatut <> '') } if ($viewstatut == -3) // To bill { - $sql.= ' AND c.fk_statut in (1,2,3)'; - $sql.= ' AND c.facture = 0'; // invoice not created + //$sql.= ' AND c.fk_statut in (1,2,3)'; + //$sql.= ' AND c.facture = 0'; // invoice not created + $sql .= ' AND ((c.fk_statut IN (1,2)) OR (c.fk_statut = 3 AND c.facture = 0))'; // validated, in process or closed but not billed } } if ($ordermonth > 0) From 16facc81aa16d5130b4c29ffb6601ac02488477d Mon Sep 17 00:00:00 2001 From: jean Date: Fri, 26 Sep 2014 10:11:38 +0200 Subject: [PATCH 4/4] Add link with order when invoice made for a shioppoing --- htdocs/compta/facture.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php index 00c927bad99..168beb73b43 100644 --- a/htdocs/compta/facture.php +++ b/htdocs/compta/facture.php @@ -865,6 +865,16 @@ else if ($action == 'add' && $user->rights->facture->creer) // Possibility to add external linked objects with hooks $object->linked_objects [$object->origin] = $object->origin_id; + // link with order if it is a shipping invoice + if ($object->origin == 'shipping') + { + require_once DOL_DOCUMENT_ROOT . '/expedition/class/expedition.class.php'; + $exp = new Expedition($db); + $exp->fetch($object->origin_id); + $exp->fetchObjectLinked(); + if (count ($exp->linkedObjectsIds['commande']) > 0) $object->linked_objects['commande'] = $exp->linkedObjectsIds['commande'][0]; + } + if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) { $object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']); }