This commit is contained in:
Laurent Destailleur 2018-10-09 17:06:08 +02:00
commit 01c32525df
7 changed files with 47 additions and 13 deletions

View File

@ -60,11 +60,15 @@ $now = dol_now();
if ($user->societe_id > 0) if ($user->societe_id > 0)
accessforbidden(); accessforbidden();
$hookmanager->initHooks(array('sellsjournal'));
$parameters=array();
/* /*
* Actions * Actions
*/ */
$reshook=$hookmanager->executeHooks('doActions',$parameters,$user,$action); // Note that $action and $object may have been modified by some hooks
// Get informations of journal // Get informations of journal
$accountingjournalstatic = new AccountingJournal($db); $accountingjournalstatic = new AccountingJournal($db);
$accountingjournalstatic->fetch($id_journal); $accountingjournalstatic->fetch($id_journal);

View File

@ -1615,7 +1615,7 @@ if ($id > 0)
$delallowed=$user->rights->agenda->myactions->create; $delallowed=$user->rights->agenda->myactions->create;
print $formfile->showdocuments('agenda',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,0,0,'','','',$object->default_lang); print $formfile->showdocuments('actions',$object->id,$filedir,$urlsource,$genallowed,$delallowed,'',0,0,0,0,0,'','','',$object->default_lang);
print '</div><div class="fichehalfright"><div class="ficheaddleft">'; print '</div><div class="fichehalfright"><div class="ficheaddleft">';

View File

@ -84,8 +84,8 @@ class FactureStats extends Stats
$this->where.=" AND f.fk_soc = ".$this->socid; $this->where.=" AND f.fk_soc = ".$this->socid;
} }
if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid; if ($this->userid > 0) $this->where.=' AND f.fk_user_author = '.$this->userid;
if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2)"; if (! empty($conf->global->FACTURE_DEPOSITS_ARE_JUST_PAYMENTS)) $this->where.= " AND f.type IN (0,1,2,5)";
else $this->where.= " AND f.type IN (0,1,2,3)"; else $this->where.= " AND f.type IN (0,1,2,3,5)";
} }

View File

@ -464,7 +464,7 @@ if ($search_month > 0)
if ($search_year > 0 && empty($search_day)) if ($search_year > 0 && empty($search_day))
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'"; $sql.= " AND f.datef BETWEEN '".$db->idate(dol_get_first_day($search_year,$search_month,false))."' AND '".$db->idate(dol_get_last_day($search_year,$search_month,false))."'";
else if ($search_year > 0 && ! empty($search_day)) else if ($search_year > 0 && ! empty($search_day))
$sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $serch_year))."'"; $sql.= " AND f.datef BETWEEN '".$db->idate(dol_mktime(0, 0, 0, $search_month, $search_day, $search_year))."' AND '".$db->idate(dol_mktime(23, 59, 59, $search_month, $search_day, $search_year))."'";
else else
$sql.= " AND date_format(f.datef, '%m') = '".$search_month."'"; $sql.= " AND date_format(f.datef, '%m') = '".$search_month."'";
} }

View File

@ -1303,6 +1303,8 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
global $param; global $param;
dol_include_once('/comm/action/class/actioncomm.class.php');
// Check parameters // Check parameters
if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('','BadParameter'); if (! is_object($filterobj) && ! is_object($objcon)) dol_print_error('','BadParameter');
@ -1351,6 +1353,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'"; $sql.= " AND a.fk_element = o.rowid AND a.elementtype = 'product'";
if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id; if ($filterobj->id) $sql.= " AND a.fk_element = ".$filterobj->id;
} }
//TODO check how ot work with new table actioncomm_resources and multiple contact affectation
if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id; if (is_object($objcon) && $objcon->id) $sql.= " AND a.fk_contact = ".$objcon->id;
// Condition on actioncode // Condition on actioncode
if (! empty($actioncode)) if (! empty($actioncode))
@ -1387,6 +1390,14 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
{ {
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$contactaction = new ActionComm($db);
$contactaction->id=$obj->id;
$result = $contactaction->fetchResources();
if ($result<0) {
dol_print_error($db);
setEventMessage("company.lib::show_actions_done Error fetch ressource",'errors');
}
//if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))"; //if ($donetodo == 'todo') $sql.= " AND ((a.percent >= 0 AND a.percent < 100) OR (a.percent = -1 AND a.datep > '".$db->idate($now)."'))";
//if ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))"; //if ($donetodo == 'done') $sql.= " AND (a.percent = 100 OR (a.percent = -1 AND a.datep <= '".$db->idate($now)."'))";
$tododone=''; $tododone='';
@ -1408,6 +1419,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
'userphoto'=>$obj->user_photo, 'userphoto'=>$obj->user_photo,
'contact_id'=>$obj->fk_contact, 'contact_id'=>$obj->fk_contact,
'socpeopleassigned' => $contactaction->socpeopleassigned,
'lastname'=>$obj->lastname, 'lastname'=>$obj->lastname,
'firstname'=>$obj->firstname, 'firstname'=>$obj->firstname,
'fk_element'=>$obj->fk_element, 'fk_element'=>$obj->fk_element,
@ -1561,7 +1573,7 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("Label"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("Date"), 0, $_SERVER["PHP_SELF"], 'a.datep,a.id', '', $param, 'align="center"', $sortfield, $sortorder);
$out.=getTitleFieldOfList(''); $out.=getTitleFieldOfList('');
$out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], 'a.fk_contact', '', $param, '', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("ActionOnContact"), 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder);
$out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder); $out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder);
$out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch '); $out.=getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', '', $param, '', $sortfield, $sortorder, 'maxwidthsearch ');
$out.='</tr>'; $out.='</tr>';
@ -1715,10 +1727,28 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
$contactstatic->firstname=$histo[$key]['firstname']; $contactstatic->firstname=$histo[$key]['firstname'];
$contactstatic->id=$histo[$key]['contact_id']; $contactstatic->id=$histo[$key]['contact_id'];
$out.='<td width="120">'.$contactstatic->getNomUrl(1,'',10).'</td>'; $out.='<td width="120">'.$contactstatic->getNomUrl(1,'',10).'</td>';
} } elseif (isset($histo[$key]['socpeopleassigned']) && is_array($histo[$key]['socpeopleassigned']) && count($histo[$key]['socpeopleassigned']) > 0) {
else $out .= '<td>';
{ foreach ( $histo[$key]['socpeopleassigned'] as $cid => $Tab ) {
$out.='<td>&nbsp;</td>'; $contact = new Contact($db);
$result = $contact->fetch($cid);
if ($result < 0)
dol_print_error($db, $contact->error);
if ($result > 0) {
$out .= $contact->getNomUrl(1);
if (isset($histo[$key]['acode']) && $histo[$key]['acode'] == 'AC_TEL') {
if (! empty($contact->phone_pro))
$out .= '(' . dol_print_phone($contact->phone_pro) . ')';
}
$out .= '<div class="paddingright"></div>';
}
}
$out .= '</td>';
}
else {
$out.='<td>&nbsp;</td>';
} }
// Status // Status

View File

@ -138,9 +138,9 @@ if ($id > 0 || ! empty($ref))
$sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,"; $sql.= " f.datef, f.paye, f.fk_statut as statut, f.type,";
if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,"; if (!$user->rights->societe->client->voir && !$socid) $sql.= " sc.fk_soc, sc.fk_user,";
$sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive $sql.= " sum(d.total_ht) as selling_price,"; // may be negative or positive
$sql.= " sum(d.qty) as qty,"; $sql.= " IF(f.type = 2, -1, 1) * sum(d.qty) as qty,"; // not always positive in case of Credit note
$sql.= " sum(d.qty * d.buy_price_ht) as buying_price,"; // always positive $sql.= " IF(f.type = 2, -1, 1) * sum(d.qty * d.buy_price_ht) as buying_price,"; // not always positive in case of Credit note
$sql.= " sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // always positive $sql.= " IF(f.type = 2, -1, 1) * sum(abs(d.total_ht) - (d.buy_price_ht * d.qty)) as marge" ; // not always positive in case of Credit note
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s"; $sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
$sql.= ", ".MAIN_DB_PREFIX."facture as f"; $sql.= ", ".MAIN_DB_PREFIX."facture as f";
$sql.= ", ".MAIN_DB_PREFIX."facturedet as d"; $sql.= ", ".MAIN_DB_PREFIX."facturedet as d";