mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-02-20 13:46:52 +01:00
New: List of interventions of thirdparties visibles into the referer
page of thirdparties.
This commit is contained in:
parent
c799f0f10f
commit
1785943580
|
|
@ -48,7 +48,7 @@ if ($page == -1) {
|
|||
}
|
||||
$offset = $conf->liste_limit * $page;
|
||||
if (! $sortorder) $sortorder='DESC';
|
||||
if (! $sortfield) $sortfield='datePrint';
|
||||
if (! $sortfield) $sortfield='dateprint';
|
||||
$limit = $conf->liste_limit;
|
||||
|
||||
// Search fields
|
||||
|
|
@ -67,10 +67,6 @@ if (GETPOST("button_removefilter"))
|
|||
}
|
||||
// Customer or supplier selected in drop box
|
||||
$thirdTypeSelect = GETPOST("third_select_id");
|
||||
if ($conf->facture->enabled && $user->rights->facture->lire)
|
||||
$type_element = 'invoice';
|
||||
elseif ($conf->commande->enabled && $user->rights->commande->lire)
|
||||
$type_element = 'order';
|
||||
$type_element = GETPOST('type_element')?GETPOST('type_element'):$type_element;
|
||||
|
||||
|
||||
|
|
@ -78,6 +74,7 @@ $langs->load("companies");
|
|||
$langs->load("bills");
|
||||
$langs->load("orders");
|
||||
$langs->load("suppliers");
|
||||
$langs->load("propal");
|
||||
|
||||
|
||||
/*
|
||||
|
|
@ -117,6 +114,8 @@ if (! empty($conf->global->SOCIETE_USEPREFIX)) // Old not used prefix field
|
|||
print '<tr><td>'.$langs->trans('Prefix').'</td><td colspan="3">'.$object->prefix_comm.'</td></tr>';
|
||||
}
|
||||
|
||||
//if ($conf->agenda->enabled && $user->rights->agenda->myactions->read) $elementTypeArray['action']=$langs->transnoentitiesnoconv('Events');
|
||||
|
||||
if ($object->client)
|
||||
{
|
||||
print '<tr><td>';
|
||||
|
|
@ -131,8 +130,10 @@ if ($object->client)
|
|||
$obj = $db->fetch_object($resql);
|
||||
$nbFactsClient = $obj->nb;
|
||||
$thirdTypeArray['customer']=$langs->trans("customer");
|
||||
if($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->trans('Invoices');
|
||||
if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->trans('Orders');
|
||||
if ($conf->propal->enabled && $user->rights->propal->lire) $elementTypeArray['propal']=$langs->transnoentitiesnoconv('Proposals');
|
||||
if ($conf->commande->enabled && $user->rights->commande->lire) $elementTypeArray['order']=$langs->transnoentitiesnoconv('Orders');
|
||||
if ($conf->facture->enabled && $user->rights->facture->lire) $elementTypeArray['invoice']=$langs->transnoentitiesnoconv('Invoices');
|
||||
if ($conf->ficheinter>enabled && $user->rights->ficheinter->lire) $elementTypeArray['fichinter']=$langs->transnoentitiesnoconv('Interventions');
|
||||
}
|
||||
|
||||
if ($object->fournisseur)
|
||||
|
|
@ -149,8 +150,8 @@ if ($object->fournisseur)
|
|||
$obj = $db->fetch_object($resql);
|
||||
$nbCmdsFourn = $obj->nb;
|
||||
$thirdTypeArray['supplier']=$langs->trans("supplier");
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice']=$langs->trans('SuppliersInvoices');
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']=$langs->trans('SuppliersOrders');
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->facture->lire) $elementTypeArray['supplier_invoice']=$langs->transnoentitiesnoconv('SuppliersInvoices');
|
||||
if ($conf->fournisseur->enabled && $user->rights->fournisseur->commande->lire) $elementTypeArray['supplier_order']=$langs->transnoentitiesnoconv('SuppliersOrders');
|
||||
}
|
||||
print '</table>';
|
||||
|
||||
|
|
@ -164,16 +165,36 @@ print '<input type="hidden" name="socid" value="'.$socid.'">'."\n";
|
|||
|
||||
|
||||
$sql_select='';
|
||||
/*if ($type_element == 'action')
|
||||
{ // Customer : show products from invoices
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
|
||||
$documentstatic=new ActionComm($db);
|
||||
$sql_select = 'SELECT f.id as doc_id, f.id as doc_number, \'1\' as doc_type, f.datep as dateprint, ';
|
||||
$tables_from = MAIN_DB_PREFIX."actioncomm as f";
|
||||
$where = " WHERE rbl.parentid = f.id AND f.entity = ".$conf->entity;
|
||||
$dateprint = 'f.datep';
|
||||
$doc_number='f.id';
|
||||
}*/
|
||||
if ($type_element == 'fichinter')
|
||||
{ // Customer : show products from invoices
|
||||
require_once DOL_DOCUMENT_ROOT.'/fichinter/class/fichinter.class.php';
|
||||
$documentstatic=new Fichinter($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datec as dateprint, ';
|
||||
$tables_from = MAIN_DB_PREFIX."fichinter as f,".MAIN_DB_PREFIX."fichinterdet as d";
|
||||
$where = " WHERE d.fk_fichinter = f.rowid AND f.entity = ".$conf->entity;
|
||||
$dateprint = 'f.datec';
|
||||
$doc_number='f.ref';
|
||||
}
|
||||
if ($type_element == 'invoice')
|
||||
{ // Customer : show products from invoices
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$documentstatic=new Facture($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as datePrint, ';
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.facnumber as doc_number, f.type as doc_type, f.datef as dateprint, ';
|
||||
$tables_from = MAIN_DB_PREFIX."facture as f,".MAIN_DB_PREFIX."facturedet as d";
|
||||
$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
$where.= " AND d.fk_facture = f.rowid";
|
||||
$where.= " AND f.entity = ".$conf->entity;
|
||||
$datePrint = 'f.datef';
|
||||
$dateprint = 'f.datef';
|
||||
$doc_number='f.facnumber';
|
||||
$thirdTypeSelect='customer';
|
||||
}
|
||||
|
|
@ -181,12 +202,25 @@ if ($type_element == 'order')
|
|||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/commande/class/commande.class.php';
|
||||
$documentstatic=new Commande($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as datePrint, ';
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_commande as dateprint, ';
|
||||
$tables_from = MAIN_DB_PREFIX."commande as c,".MAIN_DB_PREFIX."commandedet as d";
|
||||
$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
$where.= " AND d.fk_commande = c.rowid";
|
||||
$where.= " AND c.entity = ".$conf->entity;
|
||||
$datePrint = 'c.datef';
|
||||
$dateprint = 'c.datef';
|
||||
$doc_number='c.ref';
|
||||
$thirdTypeSelect='customer';
|
||||
}
|
||||
if ($type_element == 'propal')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/comm/propal/class/propal.class.php';
|
||||
$documentstatic=new Propal($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.datep as dateprint, ';
|
||||
$tables_from = MAIN_DB_PREFIX."propal as c,".MAIN_DB_PREFIX."propaldet as d";
|
||||
$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
$where.= " AND d.fk_propal = c.rowid";
|
||||
$where.= " AND c.entity = ".$conf->entity;
|
||||
$dateprint = 'c.datep';
|
||||
$doc_number='c.ref';
|
||||
$thirdTypeSelect='customer';
|
||||
}
|
||||
|
|
@ -194,11 +228,11 @@ if ($type_element == 'supplier_invoice')
|
|||
{ // Supplier : Show products from invoices.
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
|
||||
$documentstatic=new FactureFournisseur($db);
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as datePrint, ';
|
||||
$sql_select = 'SELECT f.rowid as doc_id, f.ref as doc_number, \'1\' as doc_type, f.datef as dateprint, ';
|
||||
$tables_from = MAIN_DB_PREFIX."facture_fourn as f,".MAIN_DB_PREFIX."facture_fourn_det as d";
|
||||
$where = " WHERE f.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
$where.= " AND d.fk_facture_fourn = f.rowid";
|
||||
$datePrint = 'f.datef';
|
||||
$dateprint = 'f.datef';
|
||||
$doc_number='f.ref';
|
||||
$thirdTypeSelect='supplier';
|
||||
}
|
||||
|
|
@ -206,34 +240,36 @@ if ($type_element == 'supplier_order')
|
|||
{ // Supplier : Show products from orders.
|
||||
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.commande.class.php';
|
||||
$documentstatic=new CommandeFournisseur($db);
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as datePrint, ';
|
||||
$sql_select = 'SELECT c.rowid as doc_id, c.ref as doc_number, \'1\' as doc_type, c.date_valid as dateprint, ';
|
||||
$tables_from = MAIN_DB_PREFIX."commande_fournisseur as c,".MAIN_DB_PREFIX."commande_fournisseurdet as d";
|
||||
$where = " WHERE c.fk_soc = s.rowid AND s.rowid = ".$socid;
|
||||
$where.= " AND d.fk_commande = c.rowid";
|
||||
$datePrint = 'c.date_valid';
|
||||
$dateprint = 'c.date_valid';
|
||||
$doc_number='c.ref';
|
||||
$thirdTypeSelect='supplier';
|
||||
}
|
||||
|
||||
$sql = $sql_select;
|
||||
$sql.= ' d.fk_product as product_id, d.fk_product as fk_product, d.label, d.description as description, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,';
|
||||
$sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type,';
|
||||
$sql.= " s.rowid as socid, p.ref as prod_ref, p.label as product_label";
|
||||
$sql.= ' d.description as description,';
|
||||
if ($type_element != 'fichinter') $sql.= ' d.label, d.fk_product as product_id, d.fk_product as fk_product, d.info_bits, d.date_start, d.date_end, d.qty, d.qty as prod_qty,';
|
||||
if ($type_element != 'fichinter') $sql.= ' p.ref as ref, p.rowid as prod_id, p.rowid as fk_product, p.fk_product_type as prod_type, p.fk_product_type as fk_product_type,';
|
||||
$sql.= " s.rowid as socid ";
|
||||
if ($type_element != 'fichinter') $sql.= ", p.ref as prod_ref, p.label as product_label";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s, ".$tables_from;
|
||||
$sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
|
||||
if ($type_element != 'fichinter') $sql.= ' LEFT JOIN '.MAIN_DB_PREFIX.'product as p ON d.fk_product = p.rowid ';
|
||||
$sql.= $where;
|
||||
if ($month > 0) {
|
||||
if ($year > 0) {
|
||||
$start = dol_mktime(0, 0, 0, $month, 1, $year);
|
||||
$end = dol_time_plus_duree($start,1,'m') - 1;
|
||||
$sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
|
||||
$sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
|
||||
} else {
|
||||
$sql.= " AND date_format(".$datePrint.", '%m') = '".sprintf('%02d',$month)."'";
|
||||
$sql.= " AND date_format(".$dateprint.", '%m') = '".sprintf('%02d',$month)."'";
|
||||
}
|
||||
} else if ($year > 0) {
|
||||
$start = dol_mktime(0, 0, 0, 1, 1, $year);
|
||||
$end = dol_time_plus_duree($start,1,'y') - 1;
|
||||
$sql.= " AND ".$datePrint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
|
||||
$sql.= " AND ".$dateprint." BETWEEN '".$db->idate($start)."' AND '".$db->idate($end)."'";
|
||||
}
|
||||
if ($sref) $sql.= " AND ".$doc_number." LIKE '%".$sref."%'";
|
||||
if ($sprod_fulldescr) $sql.= " AND (d.description LIKE '%".$sprod_fulldescr."%' OR p.label LIKE '%".$sprod_fulldescr."%')";
|
||||
|
|
@ -242,11 +278,11 @@ $sql.= $db->plimit($limit + 1, $offset);
|
|||
|
||||
|
||||
// Define type of elements
|
||||
$typeElementString = $form->selectarray("type_element",$elementTypeArray,GETPOST('type_element'));
|
||||
$typeElementString = $form->selectarray("type_element", $elementTypeArray, GETPOST('type_element'), 2);
|
||||
$button = '<input type="submit" class="button" name="button_third" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
|
||||
$param="&sref=".$sref."&month=".$month."&year=".$year."&sprod_fulldescr=".$sprod_fulldescr."&socid=".$socid."&type_element=".$type_element;
|
||||
|
||||
print_barre_liste($langs->trans('ProductsIntoElements', $typeElementString.' '.$button), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', '');
|
||||
print_barre_liste($langs->trans('ProductsIntoElements').' '.$typeElementString.' '.$button, $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder,'',$num, '', '');
|
||||
|
||||
if ($sql_select)
|
||||
{
|
||||
|
|
@ -258,7 +294,7 @@ print '<table class="liste" width="100%">'."\n";
|
|||
// Titles with sort buttons
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre($langs->trans('Ref'),$_SERVER['PHP_SELF'],'doc_number','',$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'datePrint','',$param,'align="center" width="150"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans('Date'),$_SERVER['PHP_SELF'],'dateprint','',$param,'align="center" width="150"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans('Product'),$_SERVER['PHP_SELF'],'','',$param,'align="left"',$sortfield,$sortorder);
|
||||
print_liste_field_titre($langs->trans('Quantity'),$_SERVER['PHP_SELF'],'prod_qty','',$param,'align="right"',$sortfield,$sortorder);
|
||||
// Filters
|
||||
|
|
@ -294,7 +330,7 @@ if ($sql_select)
|
|||
$documentstatic->type=$objp->type;
|
||||
print $documentstatic->getNomUrl(1);
|
||||
print '</td>';
|
||||
print '<td align="center" width="80">'.dol_print_date($db->jdate($objp->datePrint),'day').'</td>';
|
||||
print '<td align="center" width="80">'.dol_print_date($db->jdate($objp->dateprint),'day').'</td>';
|
||||
|
||||
print '<td>';
|
||||
|
||||
|
|
@ -440,6 +476,10 @@ if ($sql_select)
|
|||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
else if (empty($type_element) || $type_element == -1)
|
||||
{
|
||||
print '<tr><td colspan="4">'.$langs->trans("SelectElementAndClickRefresh").'</td></tr>';
|
||||
}
|
||||
else {
|
||||
print '<tr><td colspan="4">'.$langs->trans("FeatureNotYetAvailable").'</td></tr>';
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user