Merge pull request #1925 from tiaris/develop
adding hooks for supplier card and order card
This commit is contained in:
commit
ba33f73767
@ -156,8 +156,9 @@ if ($viewstatut <> '')
|
|||||||
}
|
}
|
||||||
if ($viewstatut == -3) // To bill
|
if ($viewstatut == -3) // To bill
|
||||||
{
|
{
|
||||||
$sql.= ' AND c.fk_statut in (1,2,3)';
|
//$sql.= ' AND c.fk_statut in (1,2,3)';
|
||||||
$sql.= ' AND c.facture = 0'; // invoice not created
|
//$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)
|
if ($ordermonth > 0)
|
||||||
|
|||||||
@ -866,6 +866,16 @@ else if ($action == 'add' && $user->rights->facture->creer)
|
|||||||
|
|
||||||
// Possibility to add external linked objects with hooks
|
// Possibility to add external linked objects with hooks
|
||||||
$object->linked_objects [$object->origin] = $object->origin_id;
|
$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'])) {
|
if (is_array($_POST['other_linked_objects']) && ! empty($_POST['other_linked_objects'])) {
|
||||||
$object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
|
$object->linked_objects = array_merge($object->linked_objects, $_POST['other_linked_objects']);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@
|
|||||||
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
* Copyright (C) 2005-2010 Regis Houssin <regis.houssin@capnetworks.com>
|
||||||
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
* Copyright (C) 2010-2014 Juanjo Menent <jmenent@2byte.es>
|
||||||
|
* Copyright (C) 2014 Jean Heimburger <jean@tiaris.info>
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* 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
|
* 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);
|
$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
|
* Action
|
||||||
*/
|
*/
|
||||||
@ -426,60 +430,66 @@ if ($object->fetch($id))
|
|||||||
/*
|
/*
|
||||||
* Barre d'actions
|
* Barre d'actions
|
||||||
*/
|
*/
|
||||||
|
$parameters = array();
|
||||||
print '<div class="tabsAction">';
|
$reshook = $hookmanager->executeHooks('addMoreActionsButtons', $parameters, $object, $action); // Note that $action and $object may have been
|
||||||
|
// modified by hook
|
||||||
if ($user->rights->fournisseur->commande->creer)
|
if (empty($reshook))
|
||||||
{
|
{
|
||||||
$langs->load("orders");
|
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddOrder").'</a>';
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
if ($user->rights->fournisseur->commande->creer)
|
||||||
|
{
|
||||||
|
$langs->load("orders");
|
||||||
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/commande/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddOrder").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($user->rights->fournisseur->facture->creer)
|
||||||
|
{
|
||||||
|
$langs->load("bills");
|
||||||
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add action
|
||||||
|
if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
|
||||||
|
{
|
||||||
|
if ($user->rights->agenda->myactions->create)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
print '</div>';
|
||||||
|
print '<br>';
|
||||||
|
|
||||||
|
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
|
||||||
|
{
|
||||||
|
print '<br>';
|
||||||
|
// 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 '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddBill").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add action
|
|
||||||
if (! empty($conf->agenda->enabled) && ! empty($conf->global->MAIN_REPEATTASKONEACHTAB))
|
|
||||||
{
|
|
||||||
if ($user->rights->agenda->myactions->create)
|
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&socid='.$object->id.'">'.$langs->trans("AddAction").'</a>';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
print '<a class="butAction" title="'.dol_escape_js($langs->trans("NotAllowed")).'" href="#">'.$langs->trans("AddAction").'</a>';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
print '</div>';
|
|
||||||
print '<br>';
|
|
||||||
|
|
||||||
if (! empty($conf->global->MAIN_REPEATCONTACTONEACHTAB))
|
|
||||||
{
|
|
||||||
print '<br>';
|
|
||||||
// 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
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1821,98 +1821,104 @@ elseif (! empty($object->id))
|
|||||||
/**
|
/**
|
||||||
* Boutons actions
|
* 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 '<div class="tabsAction">';
|
if ($user->societe_id == 0 && $action != 'edit_line' && $action != 'delete')
|
||||||
|
|
||||||
// Validate
|
|
||||||
if ($object->statut == 0 && $num > 0)
|
|
||||||
{
|
{
|
||||||
if ($user->rights->fournisseur->commande->valider)
|
print '<div class="tabsAction">';
|
||||||
|
|
||||||
|
// Validate
|
||||||
|
if ($object->statut == 0 && $num > 0)
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid"';
|
if ($user->rights->fournisseur->commande->valider)
|
||||||
print '>'.$langs->trans('Validate').'</a>';
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=valid"';
|
||||||
|
print '>'.$langs->trans('Validate').'</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Modify
|
||||||
// Modify
|
if ($object->statut == 1)
|
||||||
if ($object->statut == 1)
|
|
||||||
{
|
|
||||||
if ($user->rights->fournisseur->commande->commander)
|
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Modify").'</a>';
|
if ($user->rights->fournisseur->commande->commander)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("Modify").'</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Approve
|
||||||
// Approve
|
if ($object->statut == 1)
|
||||||
if ($object->statut == 1)
|
|
||||||
{
|
|
||||||
if ($user->rights->fournisseur->commande->approuver)
|
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=approve">'.$langs->trans("ApproveOrder").'</a>';
|
if ($user->rights->fournisseur->commande->approuver)
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=approve">'.$langs->trans("ApproveOrder").'</a>';
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=refuse">'.$langs->trans("RefuseOrder").'</a>';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
print '<a class="butActionRefused" href="#">'.$langs->trans("ApproveOrder").'</a>';
|
||||||
|
print '<a class="butActionRefused" href="#">'.$langs->trans("RefuseOrder").'</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
// Send
|
||||||
|
if (in_array($object->statut, array(2, 3, 4, 5)))
|
||||||
{
|
{
|
||||||
print '<a class="butActionRefused" href="#">'.$langs->trans("ApproveOrder").'</a>';
|
if ($user->rights->fournisseur->commande->commander)
|
||||||
print '<a class="butActionRefused" href="#">'.$langs->trans("RefuseOrder").'</a>';
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Reopen
|
||||||
// Send
|
if (in_array($object->statut, array(2, 5, 6, 7, 9)))
|
||||||
if (in_array($object->statut, array(2, 3, 4, 5)))
|
|
||||||
{
|
|
||||||
if ($user->rights->fournisseur->commande->commander)
|
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=presend&mode=init">'.$langs->trans('SendByMail').'</a>';
|
if ($user->rights->fournisseur->commande->commander)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Create bill
|
||||||
// Reopen
|
if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted
|
||||||
if (in_array($object->statut, array(2, 5, 6, 7, 9)))
|
|
||||||
{
|
|
||||||
if ($user->rights->fournisseur->commande->commander)
|
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=reopen">'.$langs->trans("ReOpen").'</a>';
|
if ($user->rights->fournisseur->facture->creer)
|
||||||
|
{
|
||||||
|
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
//if ($user->rights->fournisseur->commande->creer && $object->statut > 2)
|
||||||
|
//{
|
||||||
|
// print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
// Cancel
|
||||||
// Create bill
|
if ($object->statut == 2)
|
||||||
if (! empty($conf->fournisseur->enabled) && $object->statut >= 2) // 2 means accepted
|
|
||||||
{
|
|
||||||
if ($user->rights->fournisseur->facture->creer)
|
|
||||||
{
|
{
|
||||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/fourn/facture/card.php?action=create&origin='.$object->element.'&originid='.$object->id.'&socid='.$object->socid.'">'.$langs->trans("CreateBill").'</a>';
|
if ($user->rights->fournisseur->commande->commander)
|
||||||
|
{
|
||||||
|
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel">'.$langs->trans("CancelOrder").'</a>';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//if ($user->rights->fournisseur->commande->creer && $object->statut > 2)
|
// Clone
|
||||||
//{
|
if ($user->rights->fournisseur->commande->creer)
|
||||||
// print '<a class="butAction" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=classifybilled">'.$langs->trans("ClassifyBilled").'</a>';
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cancel
|
|
||||||
if ($object->statut == 2)
|
|
||||||
{
|
|
||||||
if ($user->rights->fournisseur->commande->commander)
|
|
||||||
{
|
{
|
||||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=cancel">'.$langs->trans("CancelOrder").'</a>';
|
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=order">'.$langs->trans("ToClone").'</a>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Delete
|
||||||
|
if ($user->rights->fournisseur->commande->supprimer)
|
||||||
|
{
|
||||||
|
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
||||||
|
}
|
||||||
|
|
||||||
|
print "</div>";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clone
|
|
||||||
if ($user->rights->fournisseur->commande->creer)
|
|
||||||
{
|
|
||||||
print '<a class="butAction" href="'.$_SERVER['PHP_SELF'].'?id='.$object->id.'&socid='.$object->socid.'&action=clone&object=order">'.$langs->trans("ToClone").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
// Delete
|
|
||||||
if ($user->rights->fournisseur->commande->supprimer)
|
|
||||||
{
|
|
||||||
print '<a class="butActionDelete" href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=delete">'.$langs->trans("Delete").'</a>';
|
|
||||||
}
|
|
||||||
|
|
||||||
print "</div>";
|
|
||||||
}
|
}
|
||||||
print "<br>";
|
print "<br>";
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user