From 82052450a6c6a91583263760a646542bf228057f Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 26 Dec 2016 18:21:18 +0100 Subject: [PATCH] Complete work on dol_banner --- htdocs/comm/action/card.php | 7 +- htdocs/core/lib/company.lib.php | 20 ++- htdocs/core/lib/fourn.lib.php | 10 +- htdocs/fourn/commande/contact.php | 2 +- htdocs/fourn/commande/dispatch.php | 4 +- htdocs/fourn/commande/info.php | 250 +++++++++++++++++++---------- htdocs/projet/info.php | 15 +- 7 files changed, 206 insertions(+), 102 deletions(-) diff --git a/htdocs/comm/action/card.php b/htdocs/comm/action/card.php index 4b6380b1240..b4a9f8b5395 100644 --- a/htdocs/comm/action/card.php +++ b/htdocs/comm/action/card.php @@ -278,7 +278,7 @@ if ($action == 'add') if (GETPOST("doneby") > 0) $object->userdoneid = GETPOST("doneby","int"); } - $object->note = trim($_POST["note"]); + $object->note = trim(GETPOST("note")); if (isset($_POST["contactid"])) $object->contact = $contact; @@ -290,11 +290,6 @@ if ($action == 'add') $object->societe = $object->thirdparty; // For backward compatibility } - // Special for module webcal and phenix - // TODO external modules - if (! empty($conf->webcalendar->enabled) && GETPOST('add_webcal') == 'on') $object->use_webcal=1; - if (! empty($conf->phenix->enabled) && GETPOST('add_phenix') == 'on') $object->use_phenix=1; - // Check parameters if (empty($object->userownerid) && empty($_SESSION['assignedtouser'])) { diff --git a/htdocs/core/lib/company.lib.php b/htdocs/core/lib/company.lib.php index ff6459413a4..ccec6af47d0 100644 --- a/htdocs/core/lib/company.lib.php +++ b/htdocs/core/lib/company.lib.php @@ -993,16 +993,26 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $sql.= " u.login, u.rowid as user_id"; if (get_class($filterobj) == 'Societe') $sql.= ", sp.lastname, sp.firstname"; if (get_class($filterobj) == 'Adherent') $sql.= ", m.lastname, m.firstname"; + if (get_class($filterobj) == 'CommandeFournisseur') $sql.= ", o.ref"; $sql.= " FROM ".MAIN_DB_PREFIX."user as u, ".MAIN_DB_PREFIX."actioncomm as a"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."c_actioncomm as c ON a.fk_action = c.id"; if (get_class($filterobj) == 'Societe') $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."socpeople as sp ON a.fk_contact = sp.rowid"; if (get_class($filterobj) == 'Adherent') $sql.= ", ".MAIN_DB_PREFIX."adherent as m"; + if (get_class($filterobj) == 'CommandeFournisseur') $sql.= ", ".MAIN_DB_PREFIX."commande_fournisseur as o"; $sql.= " WHERE u.rowid = a.fk_user_author"; $sql.= " AND a.entity IN (".getEntity('agenda', 1).")"; if (get_class($filterobj) == 'Societe' && $filterobj->id) $sql.= " AND a.fk_soc = ".$filterobj->id; if (get_class($filterobj) == 'Project' && $filterobj->id) $sql.= " AND a.fk_project = ".$filterobj->id; - if (get_class($filterobj) == 'Adherent') $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; - if (get_class($filterobj) == 'Adherent' && $filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + if (get_class($filterobj) == 'Adherent') + { + $sql.= " AND a.fk_element = m.rowid AND a.elementtype = 'member'"; + if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + } + if (get_class($filterobj) == 'CommandeFournisseur') + { + $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'order_supplier'"; + if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; + } if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id; // Condition on actioncode if (! empty($actioncode)) @@ -1133,6 +1143,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php'; require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php'; require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php'; + require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php'; require_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; @@ -1142,9 +1153,10 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= $userstatic=new User($db); $contactstatic = new Contact($db); - // TODO uniformize + // TODO mutualize/uniformize $propalstatic=new Propal($db); $orderstatic=new Commande($db); + $supplierorderstatic=new CommandeFournisseur($db); $facturestatic=new Facture($db); $out.='
'; @@ -1286,7 +1298,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint= //$out.=''.dol_trunc($histo[$key]['note'], 40).''; // Objet lie - // TODO uniformize + // TODO mutualize/uniformize $out.=''; //var_dump($histo[$key]['elementtype']); if (isset($histo[$key]['elementtype'])) diff --git a/htdocs/core/lib/fourn.lib.php b/htdocs/core/lib/fourn.lib.php index 4c277a69968..3ac3cf49a9c 100644 --- a/htdocs/core/lib/fourn.lib.php +++ b/htdocs/core/lib/fourn.lib.php @@ -101,7 +101,8 @@ function facturefourn_prepare_head($object) */ function ordersupplier_prepare_head($object) { - global $db, $langs, $conf; + global $db, $langs, $conf, $user; + $h = 0; $head = array(); @@ -159,7 +160,12 @@ function ordersupplier_prepare_head($object) $h++; $head[$h][0] = DOL_URL_ROOT.'/fourn/commande/info.php?id='.$object->id; - $head[$h][1] = $langs->trans("Info"); + $head[$h][1].= $langs->trans("Events"); + if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) )) + { + $head[$h][1].= '/'; + $head[$h][1].= $langs->trans("Agenda"); + } $head[$h][2] = 'info'; $h++; complete_head_from_modules($conf,$langs,$object,$head,$h,'supplier_order', 'remove'); diff --git a/htdocs/fourn/commande/contact.php b/htdocs/fourn/commande/contact.php index 04bb5a24506..564057d991a 100644 --- a/htdocs/fourn/commande/contact.php +++ b/htdocs/fourn/commande/contact.php @@ -184,7 +184,7 @@ if ($id > 0 || ! empty($ref)) $morehtmlref.=''; - dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, '', 0, '', '', 1); dol_fiche_end(); diff --git a/htdocs/fourn/commande/dispatch.php b/htdocs/fourn/commande/dispatch.php index 7de5d34d248..d8d60e96272 100644 --- a/htdocs/fourn/commande/dispatch.php +++ b/htdocs/fourn/commande/dispatch.php @@ -625,9 +625,9 @@ if ($id > 0 || ! empty($ref)) { // Message if nothing to dispatch if (! $nbproduct) { if (empty($conf->global->SUPPLIER_ORDER_DISABLE_STOCK_DISPATCH_WHEN_TOTAL_REACHED)) - print $langs->trans("NoPredefinedProductToDispatch"); // No predefined line at all + print '
'.$langs->trans("NoPredefinedProductToDispatch").'
'; // No predefined line at all else - print $langs->trans("NoMorePredefinedProductToDispatch"); // No predefined line that remain to be dispatched. + print '
'.$langs->trans("NoMorePredefinedProductToDispatch").'
'; // No predefined line that remain to be dispatched. } print '
'; diff --git a/htdocs/fourn/commande/info.php b/htdocs/fourn/commande/info.php index 5cd8510d854..d858dc7172c 100644 --- a/htdocs/fourn/commande/info.php +++ b/htdocs/fourn/commande/info.php @@ -27,6 +27,7 @@ require '../../main.inc.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/fourn.lib.php'; require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php'; require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/lib/company.lib.php'; $langs->load("orders"); $langs->load("suppliers"); @@ -35,11 +36,44 @@ $langs->load('stocks'); $id=GETPOST('id','int'); $ref=GETPOST('ref','alpha'); +$action = GETPOST('action','alpha'); + +if (GETPOST('actioncode','array')) +{ + $actioncode=GETPOST('actioncode','array',3); + if (! count($actioncode)) $actioncode='0'; +} +else +{ + $actioncode=GETPOST("actioncode","alpha",3)?GETPOST("actioncode","alpha",3):(GETPOST("actioncode")=='0'?'0':(empty($conf->global->AGENDA_DEFAULT_FILTER_TYPE)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE)); +} +$search_agenda_label=GETPOST('search_agenda_label'); // Security check -$socid=''; -if (! empty($user->societe_id)) $socid=$user->societe_id; -$result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); +$socid=0; +if ($user->societe_id) $socid=$user->societe_id; +$result=restrictedArea($user,'fournisseur',$id,'', 'commande'); + +if (!$user->rights->fournisseur->commande->lire) accessforbidden(); + + + + +/* + * Actions + */ + +$parameters=array('id'=>$id); +$reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks +if ($reshook < 0) setEventMessages($hookmanager->error, $hookmanager->errors, 'errors'); + +// Purge search criteria +if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETPOST("button_removefilter")) // All test are required to be compatible with all browsers +{ + $actioncode=''; + $search_agenda_label=''; +} + /* @@ -47,89 +81,143 @@ $result = restrictedArea($user, 'fournisseur', $id, '', 'commande'); */ $form = new Form($db); - -$now=dol_now(); +$object = new CommandeFournisseur($db); if ($id > 0 || ! empty($ref)) { - $soc = new Societe($db); - $object = new CommandeFournisseur($db); - - $result=$object->fetch($id,$ref); - if ($result >= 0) - { - $object->info($object->id); - - $soc->fetch($object->socid); - - $help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; - llxHeader('',$langs->trans("Order"),$help_url); - - $head = ordersupplier_prepare_head($object); - - $title=$langs->trans("SupplierOrder"); - dol_fiche_head($head, 'info', $title, 0, 'order'); - - - /* - * Commande - */ - - print ''; - - $linkback = ''.$langs->trans("BackToList").''; - - // Ref - print ''; - print ''; - print ''; - - // Fournisseur - print '"; - print ''; - print ''; - - // Statut - print ''; - print ''; - print '"; - - // Date - if ($object->methode_commande_id > 0) - { - print '"; - - if ($object->methode_commande) - { - print ''; - } - } - - print "
'.$langs->trans("Ref").''; - print $form->showrefnav($object, 'ref', $linkback, 1, 'ref', 'ref'); - print '
'.$langs->trans("Supplier")."'.$soc->getNomUrl(1,'supplier').'
'.$langs->trans("Status").''; - print $object->getLibStatut(4); - print "
'.$langs->trans("Date").''; - if ($object->date_commande) - { - print dol_print_date($object->date_commande,"dayhourtext")."\n"; - } - print "
'.$langs->trans("Method").''.$object->getInputMethod().'
\n"; - print "
"; - - print '
'; - dol_print_object_info($object, 1); - print '
'; - - print ''; - } - else - { - /* Order not found */ - print "OrderNotFound"; - } + $object->fetch($id, $ref); + $object->fetch_thirdparty(); + $object->info($object->id); } +$title=$langs->trans("SupplierOrder").' - '.$object->ref.' '.$object->name; +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info"); +$help_url='EN:Module_Suppliers_Orders|FR:CommandeFournisseur|ES:Módulo_Pedidos_a_proveedores'; +llxHeader('',$title,$help_url); + +$now=dol_now(); + +$head = ordersupplier_prepare_head($object); + + +dol_fiche_head($head, 'info', $langs->trans("SupplierOrder"), 0, 'order'); + + +// Supplier order card + +$linkback = ''.$langs->trans("BackToList").''; + +$morehtmlref='
'; +// Ref supplier +$morehtmlref.=$form->editfieldkey("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', 0, 1); +$morehtmlref.=$form->editfieldval("RefSupplier", 'ref_supplier', $object->ref_supplier, $object, 0, 'string', '', null, null, '', 1); +// Thirdparty +$morehtmlref.='
'.$langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1); +// Project +if (! empty($conf->projet->enabled)) +{ + $langs->load("projects"); + $morehtmlref.='
'.$langs->trans('Project') . ' '; + if ($user->rights->fournisseur->commande->creer) + { + if ($action != 'classify') + //$morehtmlref.='' . img_edit($langs->transnoentitiesnoconv('SetProject')) . ' : '; + $morehtmlref.=' : '; + if ($action == 'classify') { + //$morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'projectid', 0, 0, 1, 1); + $morehtmlref.='
'; + $morehtmlref.=''; + $morehtmlref.=''; + $morehtmlref.=$formproject->select_projects($object->socid, $object->fk_project, 'projectid', $maxlength, 0, 1, 0, 1, 0, 0, '', 1); + $morehtmlref.=''; + $morehtmlref.='
'; + } else { + $morehtmlref.=$form->form_project($_SERVER['PHP_SELF'] . '?id=' . $object->id, $object->socid, $object->fk_project, 'none', 0, 0, 0, 1); + } + } else { + if (! empty($object->fk_project)) { + $proj = new Project($db); + $proj->fetch($object->fk_project); + $morehtmlref.=''; + $morehtmlref.=$proj->ref; + $morehtmlref.=''; + } else { + $morehtmlref.=''; + } + } +} +$morehtmlref.='
'; + +dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref); + + +print '
'; +print '
'; + +dol_print_object_info($object, 1); + +print '
'; + +print '
'; + +dol_fiche_end(); + + + + +// Actions buttons + +$out=''; +$permok=$user->rights->agenda->myactions->create; +if ($permok) +{ + $out.='&originid='.$object->id.'&origin=order_supplier'; +} + + +print '
'; + +if (! empty($conf->agenda->enabled)) +{ + if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create)) + { + print ''.$langs->trans("AddAction").''; + } + else + { + print ''.$langs->trans("AddAction").''; + } +} + +print '
'; + + +if (!empty($object->id)) +{ + $param='&id='.$object->id; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + + print load_fiche_titre($langs->trans("ActionsOnOrder"),'',''); + + // List of actions on element + /*include_once DOL_DOCUMENT_ROOT.'/core/class/html.formactions.class.php'; + $formactions=new FormActions($db); + $somethingshown=$formactions->showactions($object,'project',0);*/ + + // List of todo actions + //show_actions_todo($conf,$langs,$db,$object,null,0,$actioncode); + + // List of done actions + //show_actions_done($conf,$langs,$db,$object,null,0,$actioncode); + + // List of all actions + $filters=array(); + $filters['search_agenda_label']=$search_agenda_label; + show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters); +} + + llxFooter(); $db->close(); diff --git a/htdocs/projet/info.php b/htdocs/projet/info.php index 8b6bf3c0288..0c37f999259 100644 --- a/htdocs/projet/info.php +++ b/htdocs/projet/info.php @@ -48,7 +48,6 @@ $search_agenda_label=GETPOST('search_agenda_label'); // Security check $socid=0; -$id = GETPOST("id",'int'); if ($user->societe_id) $socid=$user->societe_id; $result=restrictedArea($user,'projet',$id,''); @@ -80,11 +79,6 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter.x") || GETP $form = new Form($db); $object = new Project($db); -$title=$langs->trans("Project").' - '.$object->ref.' '.$object->name; -if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info"); -$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; -llxHeader("",$title,$help_url); - if ($id > 0 || ! empty($ref)) { $object->fetch($id, $ref); @@ -92,6 +86,11 @@ if ($id > 0 || ! empty($ref)) $object->info($object->id); } +$title=$langs->trans("Project").' - '.$object->ref.' '.$object->name; +if (! empty($conf->global->MAIN_HTML_TITLE) && preg_match('/projectnameonly/',$conf->global->MAIN_HTML_TITLE) && $object->name) $title=$object->ref.' '.$object->name.' - '.$langs->trans("Info"); +$help_url="EN:Module_Projects|FR:Module_Projets|ES:Módulo_Proyectos"; +llxHeader("",$title,$help_url); + $head = project_prepare_head($object); dol_fiche_head($head, 'agenda', $langs->trans("Project"), 0, ($object->public?'projectpub':'project')); @@ -162,6 +161,10 @@ print ''; if (!empty($object->id)) { + $param='&id='.$object->id; + if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage; + if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit; + print load_fiche_titre($langs->trans("ActionsOnProject"),'',''); // List of actions on element