Merge remote-tracking branch 'refs/remotes/Dolibarr/develop' into develop
This commit is contained in:
commit
a4726eba20
@ -126,7 +126,7 @@
|
||||
<rule ref="Generic.Metrics.CyclomaticComplexity">
|
||||
<properties>
|
||||
<property name="complexity" value="120" />
|
||||
<property name="absoluteComplexity" value="250" />
|
||||
<property name="absoluteComplexity" value="300" />
|
||||
</properties>
|
||||
</rule>
|
||||
<rule ref="Generic.Metrics.NestingLevel">
|
||||
|
||||
@ -87,9 +87,6 @@ $hookmanager->initHooks(array('admin'));
|
||||
// This page is a generic page to edit dictionaries
|
||||
// Put here declaration of dictionaries properties
|
||||
|
||||
// Sort order to show dictionary (0 is space). All other dictionaries (added by modules) will be at end of this.
|
||||
$taborder=array(9,0,4,3,2,0,1,8,19,16,27,0,5,11,0,33,34,0,6,0,29,0,7,17,24,28,0,10,23,12,13,0,14,0,22,20,18,21,0,15,30,0,25,0,26,0,31,32,0);
|
||||
|
||||
// Name of SQL tables of dictionaries
|
||||
$tabname=array();
|
||||
|
||||
@ -148,75 +145,10 @@ $tabfieldcheck=array();
|
||||
$tabfieldcheck[31] = array();
|
||||
$tabfieldcheck[32] = array();
|
||||
|
||||
// Complete all arrays with entries found into modules
|
||||
complete_dictionary_with_modules($taborder,$tabname,$tablib,$tabsql,$tabsqlsort,$tabfield,$tabfieldvalue,$tabfieldinsert,$tabrowid,$tabcond,$tabhelp,$tabfieldcheck);
|
||||
|
||||
|
||||
// Define elementList and sourceList (used for dictionary type of contacts "llx_c_type_contact")
|
||||
$elementList = array();
|
||||
$sourceList=array();
|
||||
if ($id == 11)
|
||||
{
|
||||
$langs->load("orders");
|
||||
$langs->load("contracts");
|
||||
$langs->load("projects");
|
||||
$langs->load("propal");
|
||||
$langs->load("bills");
|
||||
$langs->load("interventions");
|
||||
$elementList = array(
|
||||
'' => '',
|
||||
'societe' => $langs->trans('ThirdParty'),
|
||||
// 'proposal' => $langs->trans('Proposal'),
|
||||
// 'order' => $langs->trans('Order'),
|
||||
// 'invoice' => $langs->trans('Bill'),
|
||||
'invoice_supplier' => $langs->trans('SupplierBill'),
|
||||
'order_supplier' => $langs->trans('SupplierOrder'),
|
||||
// 'intervention' => $langs->trans('InterventionCard'),
|
||||
// 'contract' => $langs->trans('Contract'),
|
||||
'project' => $langs->trans('Project'),
|
||||
'project_task' => $langs->trans('Task'),
|
||||
'agenda' => $langs->trans('Agenda'),
|
||||
// old deprecated
|
||||
'contrat' => $langs->trans('Contract'),
|
||||
'propal' => $langs->trans('Proposal'),
|
||||
'commande' => $langs->trans('Order'),
|
||||
'facture' => $langs->trans('Bill'),
|
||||
'resource' => $langs->trans('Resource'),
|
||||
// 'facture_fourn' => $langs->trans('SupplierBill'),
|
||||
'fichinter' => $langs->trans('InterventionCard')
|
||||
);
|
||||
if (! empty($conf->global->MAIN_SUPPORT_SHARED_CONTACT_BETWEEN_THIRDPARTIES)) $elementList["societe"] = $langs->trans('ThirdParty');
|
||||
|
||||
complete_elementList_with_modules($elementList);
|
||||
|
||||
asort($elementList);
|
||||
$sourceList = array(
|
||||
'internal' => $langs->trans('Internal'),
|
||||
'external' => $langs->trans('External')
|
||||
);
|
||||
}
|
||||
if ($id == 25)
|
||||
{
|
||||
// We save list of template email Dolibarr can manage. This list can found by a grep into code on "->param['models']"
|
||||
$elementList = array();
|
||||
if ($conf->propal->enabled) $elementList['propal_send']=$langs->trans('MailToSendProposal');
|
||||
if ($conf->commande->enabled) $elementList['order_send']=$langs->trans('MailToSendOrder');
|
||||
if ($conf->facture->enabled) $elementList['facture_send']=$langs->trans('MailToSendInvoice');
|
||||
if ($conf->expedition->enabled) $elementList['shipping_send']=$langs->trans('MailToSendShipment');
|
||||
if ($conf->ficheinter->enabled) $elementList['fichinter_send']=$langs->trans('MailToSendIntervention');
|
||||
if ($conf->supplier_proposal->enabled) $elementList['supplier_proposal_send']=$langs->trans('MailToSendSupplierRequestForQuotation');
|
||||
if ($conf->fournisseur->enabled) $elementList['order_supplier_send']=$langs->trans('MailToSendSupplierOrder');
|
||||
if ($conf->fournisseur->enabled) $elementList['invoice_supplier_send']=$langs->trans('MailToSendSupplierInvoice');
|
||||
if ($conf->societe->enabled) $elementList['thirdparty']=$langs->trans('MailToThirdparty');
|
||||
|
||||
$parameters=array('elementList'=>$elementList);
|
||||
$reshook=$hookmanager->executeHooks('emailElementlist',$parameters); // Note that $action and $object may have been modified by some hooks
|
||||
if ($reshook == 0) {
|
||||
foreach ($hookmanager->resArray as $item => $value) {
|
||||
$elementList[$item] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -690,7 +622,6 @@ if ($id)
|
||||
if ($fieldlist[$field]=='libelle' || $fieldlist[$field]=='label') $alabelisused=1;
|
||||
}
|
||||
|
||||
if ($id == 4) print '<td></td>';
|
||||
print '<td>';
|
||||
print '<input type="hidden" name="id" value="'.$id.'">';
|
||||
print '</td>';
|
||||
@ -731,7 +662,6 @@ if ($id)
|
||||
}
|
||||
}
|
||||
|
||||
if ($id == 4) print '<td></td>';
|
||||
print '<td colspan="3" align="right">';
|
||||
if ($tabname[$id] != MAIN_DB_PREFIX.'c_email_templates' || $action != 'edit')
|
||||
{
|
||||
@ -741,9 +671,8 @@ if ($id)
|
||||
print "</tr>";
|
||||
|
||||
$colspan=count($fieldlist)+3;
|
||||
if ($id == 4) $colspan++;
|
||||
|
||||
if (! empty($alabelisused) && $id != 25) // If there is one label among fields, we show legend of *
|
||||
if (! empty($alabelisused)) // If there is one label among fields, we show legend of *
|
||||
{
|
||||
print '<tr><td colspan="'.$colspan.'">* '.$langs->trans("LabelUsedByDefault").'.</td></tr>';
|
||||
}
|
||||
@ -775,9 +704,38 @@ if ($id)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Title of lines
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre liste_titre_add">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1; // By defaut
|
||||
|
||||
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
|
||||
|
||||
if ($showfield)
|
||||
{
|
||||
if ($value == 'country')
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" colspan="2" align="right">';
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Title of lines
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
// dans les dictionnaires de donnees
|
||||
@ -845,44 +803,11 @@ if ($id)
|
||||
print getTitleFieldOfList($valuetoshow, 0, $_SERVER["PHP_SELF"], ($sortable?$fieldlist[$field]:''), ($page?'page='.$page.'&':''), $param, "align=".$align, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
// Favorite - Only activated on country dictionary
|
||||
if ($id == 4) print getTitleFieldOfList($langs->trans("Favorite"), 0, $_SERVER["PHP_SELF"], "favorite", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
|
||||
|
||||
print getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], "active", ($page?'page='.$page.'&':''), $param, 'align="center"', $sortfield, $sortorder);
|
||||
print getTitleFieldOfList('');
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
$showfield=1; // By defaut
|
||||
|
||||
if ($fieldlist[$field]=='region_id' || $fieldlist[$field]=='country_id') { $showfield=0; }
|
||||
|
||||
if ($showfield)
|
||||
{
|
||||
if ($value == 'country')
|
||||
{
|
||||
print '<td class="liste_titre">';
|
||||
print $form->select_country($search_country_id, 'search_country_id', '', 28, 'maxwidth200 maxwidthonsmartphone');
|
||||
print '</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<td class="liste_titre"></td>';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($id == 4) print '<td></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" colspan="2" align="right">';
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
{
|
||||
// Lines with values
|
||||
@ -1090,16 +1015,6 @@ if ($id)
|
||||
if ($param) $url .= '&'.$param;
|
||||
$url.='&';
|
||||
|
||||
// Favorite
|
||||
// Only activated on country dictionary
|
||||
if ($id == 4)
|
||||
{
|
||||
print '<td align="center" class="nowrap">';
|
||||
if ($iserasable) print '<a href="'.$url.'action='.$acts[$obj->favorite].'_favorite">'.$actl[$obj->favorite].'</a>';
|
||||
else print $langs->trans("AlwaysActive");
|
||||
print '</td>';
|
||||
}
|
||||
|
||||
// Active
|
||||
print '<td align="center" class="nowrap">';
|
||||
if ($canbedisabled) print '<a href="'.$url.'action='.$acts[$obj->active].'">'.$actl[$obj->active].'</a>';
|
||||
@ -1135,65 +1050,6 @@ if ($id)
|
||||
|
||||
print '</form>';
|
||||
}
|
||||
else
|
||||
{
|
||||
/*
|
||||
* Show list of dictionary to show
|
||||
*/
|
||||
|
||||
$lastlineisempty=false;
|
||||
print '<table class="noborder" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
//print '<td>'.$langs->trans("Module").'</td>';
|
||||
print '<td colspan="2">'.$langs->trans("Dictionary").'</td>';
|
||||
print '<td>'.$langs->trans("Table").'</td>';
|
||||
print '</tr>';
|
||||
|
||||
$showemptyline='';
|
||||
foreach ($taborder as $i)
|
||||
{
|
||||
if (isset($tabname[$i]) && empty($tabcond[$i])) continue;
|
||||
|
||||
if ($i)
|
||||
{
|
||||
if ($showemptyline)
|
||||
{
|
||||
print '<tr class="oddeven"><td width="30%"> </td><td> </td><td> </td></tr>';
|
||||
$showemptyline=0;
|
||||
}
|
||||
|
||||
|
||||
$value=$tabname[$i];
|
||||
print '<tr class="oddeven"><td width="50%">';
|
||||
if (! empty($tabcond[$i]))
|
||||
{
|
||||
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$i.'">'.$langs->trans($tablib[$i]).'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print $langs->trans($tablib[$i]);
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
/*if (empty($tabcond[$i]))
|
||||
{
|
||||
print info_admin($langs->trans("DictionaryDisabledSinceNoModuleNeedIt"),1);
|
||||
}*/
|
||||
print '</td>';
|
||||
print '<td>'.$tabname[$i].'</td></tr>';
|
||||
$lastlineisempty=false;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (! $lastlineisempty)
|
||||
{
|
||||
$showemptyline=1;
|
||||
$lastlineisempty=true;
|
||||
}
|
||||
}
|
||||
}
|
||||
print '</table>';
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
|
||||
|
||||
@ -354,6 +354,7 @@ if ($action == $acts[1])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
@ -527,8 +528,25 @@ if ($id)
|
||||
print '</td></tr>';
|
||||
}
|
||||
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre_filter liste_titre_add">';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if ($filterfound)
|
||||
{
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
// Title of lines
|
||||
print '<tr class="liste_titre liste_titre_add">';
|
||||
print '<tr class="liste_titre">';
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
// Determine le nom du champ par rapport aux noms possibles
|
||||
@ -562,23 +580,6 @@ if ($id)
|
||||
print getTitleFieldOfList('');
|
||||
print '</tr>';
|
||||
|
||||
// Title line with search boxes
|
||||
print '<tr class="liste_titre_filter">';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
if ($filterfound)
|
||||
{
|
||||
$searchpicto=$form->showFilterAndCheckAddButtons(0);
|
||||
print $searchpicto;
|
||||
}
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
if ($num)
|
||||
{
|
||||
// Lines with values
|
||||
|
||||
@ -569,7 +569,7 @@ if ($action == 'create') {
|
||||
|
||||
print_liste_field_titre("AccountAccountingShort");
|
||||
print_liste_field_titre("SubledgerAccount");
|
||||
print_liste_field_titre("Labelcompte");
|
||||
print_liste_field_titre("LabelAccount");
|
||||
print_liste_field_titre("Label");
|
||||
print_liste_field_titre("Debit", "", "", "", "", 'align="right"');
|
||||
print_liste_field_titre("Credit", "", "", "", "", 'align="right"');
|
||||
|
||||
@ -98,8 +98,8 @@ $form = new Form($db);
|
||||
|
||||
|
||||
if ($action != 'export_file' && ! isset($_POST['begin']) && ! isset($_GET['begin']) && ! isset($_POST['formfilteraction']) && empty($page)) {
|
||||
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
|
||||
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
|
||||
$search_date_start = dol_mktime(0, 0, 0, 1, 1, dol_print_date(dol_now(), '%Y'));
|
||||
$search_date_end = dol_mktime(0, 0, 0, 12, 31, dol_print_date(dol_now(), '%Y'));
|
||||
}
|
||||
|
||||
|
||||
@ -134,67 +134,67 @@ if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x',
|
||||
$param = '';
|
||||
$filter = array ();
|
||||
if (! empty($search_date_start)) {
|
||||
$filter['t.doc_date>='] = $search_date_start;
|
||||
$tmp=dol_getdate($search_date_start);
|
||||
$param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year'];
|
||||
$filter['t.doc_date>='] = $search_date_start;
|
||||
$tmp=dol_getdate($search_date_start);
|
||||
$param .= '&date_startmonth=' . $tmp['mon'] . '&date_startday=' . $tmp['mday'] . '&date_startyear=' . $tmp['year'];
|
||||
}
|
||||
if (! empty($search_date_end)) {
|
||||
$filter['t.doc_date<='] = $search_date_end;
|
||||
$tmp=dol_getdate($search_date_end);
|
||||
$param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year'];
|
||||
$filter['t.doc_date<='] = $search_date_end;
|
||||
$tmp=dol_getdate($search_date_end);
|
||||
$param .= '&date_endmonth=' . $tmp['mon'] . '&date_endday=' . $tmp['mday'] . '&date_endyear=' . $tmp['year'];
|
||||
}
|
||||
if (! empty($search_doc_date)) {
|
||||
$filter['t.doc_date'] = $search_doc_date;
|
||||
$tmp=dol_getdate($search_doc_date);
|
||||
$param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year'];
|
||||
$filter['t.doc_date'] = $search_doc_date;
|
||||
$tmp=dol_getdate($search_doc_date);
|
||||
$param .= '&doc_datemonth=' . $tmp['mon'] . '&doc_dateday=' . $tmp['mday'] . '&doc_dateyear=' . $tmp['year'];
|
||||
}
|
||||
if (! empty($search_doc_type)) {
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$param .= '&search_doc_type=' . $search_doc_type;
|
||||
$filter['t.doc_type'] = $search_doc_type;
|
||||
$param .= '&search_doc_type=' . $search_doc_type;
|
||||
}
|
||||
if (! empty($search_doc_ref)) {
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$param .= '&search_doc_ref=' . $search_doc_ref;
|
||||
$filter['t.doc_ref'] = $search_doc_ref;
|
||||
$param .= '&search_doc_ref=' . $search_doc_ref;
|
||||
}
|
||||
if (! empty($search_accountancy_code)) {
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code=' . $search_accountancy_code;
|
||||
$filter['t.numero_compte'] = $search_accountancy_code;
|
||||
$param .= '&search_accountancy_code=' . $search_accountancy_code;
|
||||
}
|
||||
if (! empty($search_accountancy_code_start)) {
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
|
||||
$filter['t.numero_compte>='] = $search_accountancy_code_start;
|
||||
$param .= '&search_accountancy_code_start=' . $search_accountancy_code_start;
|
||||
}
|
||||
if (! empty($search_accountancy_code_end)) {
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
|
||||
$filter['t.numero_compte<='] = $search_accountancy_code_end;
|
||||
$param .= '&search_accountancy_code_end=' . $search_accountancy_code_end;
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code)) {
|
||||
$filter['t.subledger_account'] = $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code;
|
||||
$filter['t.subledger_account'] = $search_accountancy_aux_code;
|
||||
$param .= '&search_accountancy_aux_code=' . $search_accountancy_aux_code;
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code_start)) {
|
||||
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
|
||||
$param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
|
||||
$filter['t.subledger_account>='] = $search_accountancy_aux_code_start;
|
||||
$param .= '&search_accountancy_aux_code_start=' . $search_accountancy_aux_code_start;
|
||||
}
|
||||
if (! empty($search_accountancy_aux_code_end)) {
|
||||
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
|
||||
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
|
||||
$filter['t.subledger_account<='] = $search_accountancy_aux_code_end;
|
||||
$param .= '&search_accountancy_aux_code_end=' . $search_accountancy_aux_code_end;
|
||||
}
|
||||
if (! empty($search_mvt_label)) {
|
||||
$filter['t.label_operation'] = $search_mvt_label;
|
||||
$param .= '&search_mvt_label=' . $search_mvt_label;
|
||||
$filter['t.label_operation'] = $search_mvt_label;
|
||||
$param .= '&search_mvt_label=' . $search_mvt_label;
|
||||
}
|
||||
if (! empty($search_direction)) {
|
||||
$filter['t.sens'] = $search_direction;
|
||||
$param .= '&search_direction=' . $search_direction;
|
||||
$filter['t.sens'] = $search_direction;
|
||||
$param .= '&search_direction=' . $search_direction;
|
||||
}
|
||||
if (! empty($search_ledger_code)) {
|
||||
$filter['t.code_journal'] = $search_ledger_code;
|
||||
$param .= '&search_ledger_code=' . $search_ledger_code;
|
||||
$filter['t.code_journal'] = $search_ledger_code;
|
||||
$param .= '&search_ledger_code=' . $search_ledger_code;
|
||||
}
|
||||
if (! empty($search_mvt_num)) {
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$param .= '&search_mvt_num=' . $search_mvt_num;
|
||||
$filter['t.piece_num'] = $search_mvt_num;
|
||||
$param .= '&search_mvt_num=' . $search_mvt_num;
|
||||
}
|
||||
|
||||
if ($action == 'delbookkeeping') {
|
||||
@ -229,16 +229,16 @@ if ($action == 'delbookkeepingyearconfirm') {
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages("RecordDeleted", null, 'mesgs');
|
||||
setEventMessages("RecordDeleted", null, 'mesgs');
|
||||
}
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages("NoRecordDeleted", null, 'warnings');
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
setEventMessages("NoRecordDeleted", null, 'warnings');
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
if ($action == 'delmouvconfirm') {
|
||||
@ -248,11 +248,11 @@ if ($action == 'delmouvconfirm') {
|
||||
if (! empty($mvt_num)) {
|
||||
$result = $object->deleteMvtNum($mvt_num);
|
||||
if ($result < 0) {
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
setEventMessages($langs->trans("RecordDeleted"), null, 'mesgs');
|
||||
}
|
||||
Header("Location: list.php");
|
||||
exit;
|
||||
@ -262,21 +262,21 @@ if ($action == 'delmouvconfirm') {
|
||||
// Export into a file with format defined into setup
|
||||
if ($action == 'export_file') {
|
||||
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
||||
$result = $object->fetchAll($sortorder, $sortfield, 0, 0, $filter);
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines);
|
||||
if (!empty($accountancyexport->errors)) {
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
if ($result < 0)
|
||||
{
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
}
|
||||
else
|
||||
{
|
||||
$accountancyexport = new AccountancyExport($db);
|
||||
$accountancyexport->export($object->lines);
|
||||
if (!empty($accountancyexport->errors)) {
|
||||
setEventMessages('', $accountancyexport->errors, 'errors');
|
||||
}
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -330,7 +330,7 @@ if ($action == 'delbookkeepingyear') {
|
||||
);
|
||||
$form_question['deljournal'] = array (
|
||||
'name' => 'deljournal',
|
||||
'type' => 'other', // We don't use select here, the journal_array is already a select html component
|
||||
'type' => 'other', // We don't use select here, the journal_array is already a select html component
|
||||
'label' => $langs->trans('DelJournal'),
|
||||
'value' => $journal_array,
|
||||
'default' => $deljournal
|
||||
@ -340,7 +340,7 @@ if ($action == 'delbookkeepingyear') {
|
||||
print $formconfirm;
|
||||
}
|
||||
|
||||
//$param=''; param started before
|
||||
//$param=''; param started before
|
||||
if (! empty($contextpage) && $contextpage != $_SERVER["PHP_SELF"]) $param.='&contextpage='.$contextpage;
|
||||
if ($limit > 0 && $limit != $conf->liste_limit) $param.='&limit='.$limit;
|
||||
|
||||
@ -399,28 +399,28 @@ print '</td>';
|
||||
print '<td class="liste_titre">';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('From').' ';
|
||||
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_start, 'search_accountancy_aux_code_start', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
|
||||
print '<input type="text" name="search_accountancy_aux_code_start" value="'.$search_accountancy_aux_code_start.'">';
|
||||
}
|
||||
print '</div>';
|
||||
print '<div class="nowrap">';
|
||||
print $langs->trans('to').' ';
|
||||
// TODO For the moment we keep a fre input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// TODO For the moment we keep a free input text instead of a combo. The select_auxaccount has problem because it does not
|
||||
// use setup of keypress to select thirdparty and this hang browser on large database.
|
||||
if (! empty($conf->global->ACCOUNTANCY_COMBO_FOR_AUX))
|
||||
{
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
|
||||
print $formaccounting->select_auxaccount($search_accountancy_aux_code_end, 'search_accountancy_aux_code_end', 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
|
||||
print '<input type="text" name="search_accountancy_aux_code_end" value="'.$search_accountancy_aux_code_end.'">';
|
||||
}
|
||||
print '</div>';
|
||||
print '</td>';
|
||||
@ -489,8 +489,8 @@ while ($i < min($num, $limit))
|
||||
}
|
||||
|
||||
print '<tr class="liste_total">';
|
||||
if ($num < $limit) print '<td align="left" colspan="6">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left" colspan="6">'.$langs->trans("Totalforthispage").'</td>';
|
||||
if ($num < $limit) print '<td align="left" colspan="7">'.$langs->trans("Total").'</td>';
|
||||
else print '<td align="left" colspan="7">'.$langs->trans("Totalforthispage").'</td>';
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
print price($total_debit);
|
||||
|
||||
@ -196,7 +196,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print_liste_field_titre("Docref", "liste.php", "bk.doc_ref" );
|
||||
// print_liste_field_titre("Numerocompte", "liste.php", "bk.numero_compte" );
|
||||
// print_liste_field_titre("Code_tiers", "liste.php", "bk.code_tiers" );
|
||||
print_liste_field_titre("Labelcompte", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("Debit", "liste.php", "bk.debit" );
|
||||
print_liste_field_titre("Credit", "liste.php", "bk.credit" );
|
||||
// print_liste_field_titre("Amount", "liste.php", "bk.montant" );
|
||||
|
||||
@ -205,7 +205,7 @@ llxHeader ( '', 'Compta - Grand Livre' );
|
||||
print_liste_field_titre("Docref", "liste.php", "bk.doc_ref" );
|
||||
// print_liste_field_titre("Numerocompte", "liste.php", "bk.numero_compte" );
|
||||
// print_liste_field_titre("Code_tiers", "liste.php", "bk.code_tiers" );
|
||||
print_liste_field_titre("Labelcompte", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("LabelAccount", "liste.php", "bk_label_compte" );
|
||||
print_liste_field_titre("Debit", "liste.php", "bk.debit" );
|
||||
print_liste_field_titre("Credit", "liste.php", "bk.credit" );
|
||||
print_liste_field_titre("Amount", "liste.php", "bk.montant" );
|
||||
|
||||
@ -419,7 +419,7 @@ class AccountancyExport
|
||||
|
||||
|
||||
/**
|
||||
* Export format : Agiris
|
||||
* Export format : Agiris Isacompta
|
||||
*
|
||||
* @param array $objectLines data
|
||||
*
|
||||
@ -433,30 +433,23 @@ class AccountancyExport
|
||||
|
||||
$date = dol_print_date($line->doc_date, '%d%m%Y');
|
||||
|
||||
print $line->id . $this->separator;
|
||||
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator;
|
||||
print $line->piece_num . $this->separator;
|
||||
print $line->label_operation . $this->separator;
|
||||
print $date . $this->separator;
|
||||
print '"'.dol_trunc($line->piece_num,15,'right','UTF-8',1).'"'.$this->separator;
|
||||
print $line->label_operation . $this->separator;
|
||||
|
||||
if (empty($line->subledger_account)) {
|
||||
print length_accountg($line->numero_compte) . $this->separator;
|
||||
} else {
|
||||
// FIXME Because the subledger_account is already an accounting account, does we really need
|
||||
// to concat 4011 or 401 to it ?
|
||||
if (substr($line->numero_compte, 0, 1) == 'C' || substr($line->numero_compte, 0, 1) == '9') {
|
||||
print '411' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator;
|
||||
}
|
||||
if (substr($line->numero_compte, 0, 1) == 'F' || substr($line->numero_compte, 0, 1) == '0') {
|
||||
print '401' . substr(str_replace(" ", "", $line->subledger_account), 0, 5) . $this->separator;
|
||||
}
|
||||
print length_accounta($line->subledger_account) . $this->separator;
|
||||
}
|
||||
|
||||
print length_accounta($line->subledger_account) . $this->separator;
|
||||
print $line->doc_ref . $this->separator;
|
||||
print price($line->debit) . $this->separator;
|
||||
print price($line->credit) . $this->separator;
|
||||
print price($line->montant).$this->separator;
|
||||
print $line->sens.$this->separator;
|
||||
print $line->code_journal . $this->separator;
|
||||
print $line->code_journal;
|
||||
print $this->end_line;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
<?php
|
||||
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2016 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
/* Copyright (C) 2013 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2014 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
||||
*
|
||||
* 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
|
||||
@ -310,6 +310,7 @@ if ($resql) {
|
||||
}
|
||||
else print length_accountg($row[0]);
|
||||
print '</td>';
|
||||
|
||||
print '<td align="left">';
|
||||
if ($row[0] == 'tobind')
|
||||
{
|
||||
@ -317,7 +318,7 @@ if ($resql) {
|
||||
}
|
||||
else print $row[1];
|
||||
print '</td>';
|
||||
print '<td align="left">' . $row[1] . '</td>';
|
||||
|
||||
for($i = 2; $i <= 12; $i ++) {
|
||||
print '<td align="right">' . price($row[$i]) . '</td>';
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013 Christophe Battarel <christophe.battarel@altairis.fr>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2014 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2013-2014 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
*
|
||||
* 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
|
||||
@ -422,7 +422,6 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = $val["label"];
|
||||
$bookkeeping->label_compte = $langs->trans("Bank");
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt >= 0) ? 'D' : 'C';
|
||||
@ -433,21 +432,28 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->fk_user_author = $user->id;
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
// No subledger_account value for the bank line
|
||||
// No subledger_account value for the bank line but add a specific label_operation
|
||||
if ($tabtype[$key] == 'payment') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_supplier') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_expensereport') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
} else if ($tabtype[$key] == 'unknown') {
|
||||
// ???
|
||||
$bookkeeping->subledger_account = '';
|
||||
@ -484,7 +490,6 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->doc_type = 'bank';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
$bookkeeping->fk_docdet = $val["fk_bank"];
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'];
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0 ? - $mt : 0);
|
||||
@ -495,55 +500,55 @@ if (! $error && $action == 'writebookkeeping') {
|
||||
$bookkeeping->date_create = $now;
|
||||
|
||||
if ($tabtype[$key] == 'payment') { // If payment is payment of customer invoice, we get ref of invoice
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_supplier') { // If payment is payment of supplier invoice, we get ref of invoice
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $tabcompany[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabcompany[$key]['code_compta'];
|
||||
$bookkeeping->subledger_label = $tabcompany[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_expensereport') {
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'];
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_salary') {
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'];
|
||||
$bookkeeping->label_operation = $tabuser[$key]['name'] . ' - ' . $ref;
|
||||
$bookkeeping->subledger_account = $tabuser[$key]['accountancy_code'];
|
||||
$bookkeeping->subledger_label = $tabuser[$key]['name'];
|
||||
$bookkeeping->numero_compte = $conf->global->SALARIES_ACCOUNTING_ACCOUNT_PAYMENT;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if (in_array($tabtype[$key], array('sc', 'payment_sc'))) { // If payment is payment of social contribution
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = $objmid->labelc;
|
||||
} else if ($tabtype[$key] == 'payment_vat') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_donation') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'payment_various') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_compte = '';
|
||||
} else if ($tabtype[$key] == 'banktransfert') {
|
||||
$bookkeeping->label_operation = '';
|
||||
$bookkeeping->label_operation = $ref;
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
@ -676,9 +681,9 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans('Bank') . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . " - " . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"';
|
||||
@ -720,9 +725,9 @@ if ($action == 'exportcsv') { // ISO and not UTF8 !
|
||||
print '"' . length_accountg($conf->global->ACCOUNTING_ACCOUNT_SUSPENSE) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
if ($companystatic->name == '') {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($reflabel) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($reflabel) . '"' . $sep;
|
||||
} else {
|
||||
print '"' . $langs->trans("Bank") . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
print '"' . $val['bank_account_ref'] . ' - ' . utf8_decode($companystatic->name) . '"' . $sep;
|
||||
}
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"';
|
||||
@ -823,7 +828,7 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ObjectsRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td>" . $langs->trans("PaymentMode") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
|
||||
@ -1,11 +1,11 @@
|
||||
<?php
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||
/* Copyright (C) 2007-2010 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2007-2010 Jean Heimburger <jean@tiaris.info>
|
||||
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2013-2017 Alexandre Spangaro <aspangaro@zendsi.com>
|
||||
* Copyright (C) 2013-2016 Olivier Geffroy <jeff@jeffinfo.com>
|
||||
* Copyright (C) 2013-2016 Florian Henry <florian.henry@open-concept.pro>
|
||||
*
|
||||
* 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
|
||||
@ -298,7 +298,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]);
|
||||
$bookkeeping->label_operation = $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %';
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||
@ -552,7 +552,7 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("ExpenseReportRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
@ -659,7 +659,7 @@ if (empty($action) || $action == 'view') {
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
|
||||
print "<td>" . $userstatic->getNomUrl(0, 'user', 16) . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
|
||||
print "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
|
||||
@ -151,7 +151,7 @@ if ($result) {
|
||||
// Define array to display all VAT rates that use this accounting account $compta_tva
|
||||
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
|
||||
{
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
|
||||
}
|
||||
|
||||
$tabfac[$obj->rowid]["date"] = $db->jdate($obj->df);
|
||||
@ -224,7 +224,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_ref = $val["refsologest"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
@ -272,7 +272,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_ref = $val["refsologest"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
@ -326,7 +326,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping = new BookKeeping($db);
|
||||
$bookkeeping->doc_date = $val["date"];
|
||||
$bookkeeping->date_lim_reglement = $val["datereg"];
|
||||
$bookkeeping->doc_ref = $val["ref"];
|
||||
$bookkeeping->doc_ref = $val["refsologest"];
|
||||
$bookkeeping->date_create = $now;
|
||||
$bookkeeping->doc_type = 'supplier_invoice';
|
||||
$bookkeeping->fk_doc = $key;
|
||||
@ -335,7 +335,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'C' : 'D';
|
||||
$bookkeeping->debit = ($mt > 0) ? $mt : 0;
|
||||
@ -374,8 +374,8 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -419,7 +419,6 @@ $form = new Form($db);
|
||||
// Export
|
||||
if ($action == 'exportcsv') {
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$journal = $conf->global->ACCOUNTING_PURCHASE_JOURNAL;
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
@ -445,7 +444,7 @@ if ($action == 'exportcsv') {
|
||||
foreach ( $tabttc[$key] as $k => $mt ) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ). '"' . $sep;
|
||||
print '"' . length_accounta(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER . '"' . $sep;
|
||||
@ -465,11 +464,11 @@ if ($action == 'exportcsv') {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($accountingaccount->label, 32) ) . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
@ -478,6 +477,7 @@ if ($action == 'exportcsv') {
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
|
||||
// VAT
|
||||
$listoftax = array(0, 1, 2);
|
||||
foreach ($listoftax as $numtax) {
|
||||
@ -489,13 +489,13 @@ if ($action == 'exportcsv') {
|
||||
if ($mt) {
|
||||
print '"' . $key . '"' . $sep;
|
||||
print '"' . $date . '"' . $sep;
|
||||
print '"' . $val["refsuppliersologest"] . '"' . $sep;
|
||||
print '"' . $val["refsologest"] . '"' . $sep;
|
||||
print '"' . utf8_decode ( dol_trunc($companystatic->name, 32) ) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16) ) . ' - ' . $val["refsuppliersologest"] . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"'. $sep;
|
||||
print '"' . $journal . '"' ;
|
||||
@ -531,15 +531,15 @@ if (empty($action) || $action == 'view') {
|
||||
|
||||
// Button to write into Ledger
|
||||
if (empty($conf->global->ACCOUNTING_ACCOUNT_SUPPLIER) || $conf->global->ACCOUNTING_ACCOUNT_SUPPLIER == '-1') {
|
||||
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
print img_warning().' '.$langs->trans("SomeMandatoryStepsOfSetupWereNotDone");
|
||||
print ' : '.$langs->trans("AccountancyAreaDescMisc", 4, '<strong>'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("MenuAccountancy").'-'.$langs->transnoentitiesnoconv("Setup")."-".$langs->transnoentitiesnoconv("MenuDefaultAccounts").'</strong>');
|
||||
}
|
||||
print '<div class="tabsAction tabsActionNoBottom">';
|
||||
if (empty($conf->global->ACCOUNTING_ACCOUNT_CUSTOMER) || $conf->global->ACCOUNTING_ACCOUNT_CUSTOMER == '-1') {
|
||||
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
print '<input type="button" class="butActionRefused" title="'.dol_escape_htmltag($langs->trans("SomeMandatoryStepsOfSetupWereNotDone")).'" value="' . $langs->trans("WriteBookKeeping") . '" />';
|
||||
}
|
||||
else {
|
||||
print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
print '<input type="button" class="butAction" name="writebookkeeping" value="' . $langs->trans("WriteBookKeeping") . '" onclick="writebookkeeping();" />';
|
||||
}
|
||||
print '<input type="button" class="butAction" name="exportcsv" value="' . $langs->trans("ExportDraftJournal") . '" onclick="launch_export();" />';
|
||||
print '</div>';
|
||||
@ -565,7 +565,7 @@ if (empty($action) || $action == 'view') {
|
||||
print '<br>';
|
||||
|
||||
$i = 0;
|
||||
print '<div class="div-table-responsive">';
|
||||
print '<div class="div-table-responsive">';
|
||||
print "<table class=\"noborder\" width=\"100%\">";
|
||||
print "<tr class=\"liste_titre\">";
|
||||
print "<td></td>";
|
||||
@ -573,7 +573,7 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
@ -625,8 +625,9 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? - price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print "</tr>";
|
||||
print "</tr>";
|
||||
}
|
||||
|
||||
// Product / Service
|
||||
foreach ( $tabht[$key] as $k => $mt ) {
|
||||
$accountingaccount = new AccountingAccount($db);
|
||||
@ -683,7 +684,7 @@ if (empty($action) || $action == 'view') {
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'supplier', 16) . ' - ' . $invoicestatic->refsupplier . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
|
||||
print "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
|
||||
@ -156,7 +156,7 @@ if ($result) {
|
||||
$compta_localtax2 = (! empty($vatdata['accountancy_code_sell']) ? $vatdata['accountancy_code_sell'] : $cpttva);
|
||||
|
||||
// Define array to display all VAT rates that use this accounting account $compta_tva
|
||||
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
|
||||
if (price2num($obj->tva_tx) || ! empty($obj->vat_src_code))
|
||||
{
|
||||
$def_tva[$obj->rowid][$compta_tva][vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':'')]=(vatrate($obj->tva_tx).($obj->vat_src_code?' ('.$obj->vat_src_code.')':''));
|
||||
}
|
||||
@ -353,7 +353,7 @@ if ($action == 'writebookkeeping') {
|
||||
$bookkeeping->subledger_account = '';
|
||||
$bookkeeping->subledger_label = '';
|
||||
$bookkeeping->numero_compte = $k;
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->label_operation = dol_trunc($companystatic->name, 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT").' '.join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'');
|
||||
$bookkeeping->montant = $mt;
|
||||
$bookkeeping->sens = ($mt < 0) ? 'D' : 'C';
|
||||
$bookkeeping->debit = ($mt < 0) ? -$mt : 0;
|
||||
@ -392,8 +392,8 @@ if ($action == 'writebookkeeping') {
|
||||
|
||||
if ($error >= 10)
|
||||
{
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
setEventMessages($langs->trans("ErrorTooManyErrorsProcessStopped"), null, 'errors');
|
||||
break; // Break in the foreach
|
||||
}
|
||||
}
|
||||
|
||||
@ -441,7 +441,6 @@ $form = new Form($db);
|
||||
if ($action == 'exportcsv') {
|
||||
|
||||
$sep = $conf->global->ACCOUNTING_EXPORT_SEPARATORCSV;
|
||||
$sell_journal = $conf->global->ACCOUNTING_SELL_JOURNAL;
|
||||
|
||||
include DOL_DOCUMENT_ROOT . '/accountancy/tpl/export_journal.tpl.php';
|
||||
|
||||
@ -472,7 +471,7 @@ if ($action == 'exportcsv') {
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("Code_tiers") . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . $sell_journal . '"';
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
|
||||
@ -487,12 +486,12 @@ if ($action == 'exportcsv') {
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($accountingaccount->label, 32)) . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . dol_trunc($accountingaccount->label, 32) . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $sell_journal . '"';
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@ -512,12 +511,12 @@ if ($action == 'exportcsv') {
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 32)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print '"' . length_accountg(html_entity_decode($k)) . '"' . $sep;
|
||||
print " " . $sep;
|
||||
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . '"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
|
||||
print '""' . $sep;
|
||||
print '"' . $langs->trans("VAT") . ' - ' . $def_tva[$key] . ' %"' . $sep;
|
||||
print '"' . utf8_decode(dol_trunc($companystatic->name, 16)) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT") . join(', ',$def_tva[$key][$k]) .' %' . ($numtax?' - Localtax '.$numtax:'') . '"' . $sep;
|
||||
print '"' . ($mt < 0 ? price(- $mt) : '') . '"' . $sep;
|
||||
print '"' . ($mt >= 0 ? price($mt) : '') . '"' . $sep;
|
||||
print '"' . $sell_journal . '"';
|
||||
print '"' . $journal . '"';
|
||||
print "\n";
|
||||
}
|
||||
}
|
||||
@ -593,7 +592,7 @@ if (empty($action) || $action == 'view') {
|
||||
print "<td>" . $langs->trans("Piece") . ' (' . $langs->trans("InvoiceRef") . ")</td>";
|
||||
print "<td>" . $langs->trans("AccountAccounting") . "</td>";
|
||||
print "<td>" . $langs->trans("SubledgerAccount") . "</td>";
|
||||
print "<td>" . $langs->trans("Label") . "</td>";
|
||||
print "<td>" . $langs->trans("LabelOperation") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Debit") . "</td>";
|
||||
print "<td align='right'>" . $langs->trans("Credit") . "</td>";
|
||||
print "</tr>\n";
|
||||
@ -699,7 +698,7 @@ if (empty($action) || $action == 'view') {
|
||||
// Subledger account
|
||||
print "<td>";
|
||||
print '</td>';
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).($numtax?' - Localtax '.$numtax:'');
|
||||
print "<td>" . $companystatic->getNomUrl(0, 'customer', 16) . ' - ' . $invoicestatic->ref . ' - ' . $langs->trans("VAT"). ' '.join(', ',$def_tva[$key][$k]).' %'.($numtax?' - Localtax '.$numtax:'');
|
||||
print "</td>";
|
||||
print '<td align="right">' . ($mt < 0 ? price(- $mt) : '') . "</td>";
|
||||
print '<td align="right">' . ($mt >= 0 ? price($mt) : '') . "</td>";
|
||||
|
||||
@ -38,6 +38,28 @@ $langs->load("members");
|
||||
|
||||
$id = GETPOST('id','int')?GETPOST('id','int'):GETPOST('rowid','int');
|
||||
|
||||
$limit = GETPOST('limit','int')?GETPOST('limit','int'):$conf->liste_limit;
|
||||
$sortfield = GETPOST("sortfield",'alpha');
|
||||
$sortorder = GETPOST("sortorder",'alpha');
|
||||
$page = GETPOST("page",'int');
|
||||
if (empty($page) || $page == -1) { $page = 0; } // If $page is not defined, or '' or -1
|
||||
$offset = $limit * $page;
|
||||
$pageprev = $page - 1;
|
||||
$pagenext = $page + 1;
|
||||
if (! $sortfield) $sortfield='a.datep,a.id';
|
||||
if (! $sortorder) $sortorder='DESC';
|
||||
|
||||
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_FOR_OBJECT)?'':$conf->global->AGENDA_DEFAULT_FILTER_TYPE_FOR_OBJECT));
|
||||
}
|
||||
$search_agenda_label=GETPOST('search_agenda_label');
|
||||
|
||||
// Security check
|
||||
$result=restrictedArea($user,'adherent',$id);
|
||||
|
||||
@ -56,7 +78,26 @@ if ($result > 0)
|
||||
* Actions
|
||||
*/
|
||||
|
||||
// None
|
||||
$parameters=array('id'=>$id, 'objcanvas'=>$objcanvas);
|
||||
$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');
|
||||
|
||||
if (empty($reshook))
|
||||
{
|
||||
// Cancel
|
||||
if (GETPOST('cancel','alpha') && ! empty($backtopage))
|
||||
{
|
||||
header("Location: ".$backtopage);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Purge search criteria
|
||||
if (GETPOST('button_removefilter_x','alpha') || GETPOST('button_removefilter.x','alpha') || GETPOST('button_removefilter','alpha')) // All test are required to be compatible with all browsers
|
||||
{
|
||||
$actioncode='';
|
||||
$search_agenda_label='';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -103,25 +144,33 @@ if ($object->id > 0)
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
/*
|
||||
* Barre d'action
|
||||
*/
|
||||
//print '<div class="tabsAction">';
|
||||
//print '</div>';
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
$morehtmlcenter = '';
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
print '<div class="inline-block divButAction"><a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction").'</a></div>';
|
||||
$morehtmlcenter.='<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&backtopage=1&origin=member&originid='.$id.'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
$out='';
|
||||
$param='&id='.$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("ActionsOnMember"),$out,'');
|
||||
print_barre_liste($langs->trans("ActionsOnMember"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
|
||||
|
||||
// List of actions
|
||||
show_actions_done($conf,$langs,$db,$object,null,0,'','');
|
||||
// List of all actions
|
||||
$filters=array();
|
||||
$filters['search_agenda_label']=$search_agenda_label;
|
||||
|
||||
// TODO Replace this with same code than into listactions.php
|
||||
show_actions_done($conf,$langs,$db,$object,null,0,$actioncode, '', $filters, $sortfield, $sortorder);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -1799,10 +1799,16 @@ else
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
$MAX = 10;
|
||||
|
||||
$morehtmlright = '<a href="'.DOL_URL_ROOT.'/adherents/agenda.php?id='.$object->id.'">';
|
||||
$morehtmlright.= $langs->trans("SeeAll");
|
||||
$morehtmlright.= '</a>';
|
||||
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', 10);
|
||||
$somethingshown = $formactions->showactions($object, 'member', $socid, 1, 'listactions', $MAX, '', $morehtmlright);
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
||||
@ -1562,7 +1562,7 @@ class Adherent extends CommonObject
|
||||
*
|
||||
* @param int $withpictoimg 0=No picto, 1=Include picto into link, 2=Only picto, -1=Include photo into link, -2=Only picto photo, -3=Only photo very small)
|
||||
* @param int $maxlen length max label
|
||||
* @param string $option Page for link
|
||||
* @param string $option Page for link ('card', 'category', 'subscription', ...)
|
||||
* @param string $mode ''=Show firstname and lastname, 'firstname'=Show only firstname, 'login'=Show login, 'ref'=Show ref
|
||||
* @param string $morecss Add more css on link
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
@ -1592,10 +1592,7 @@ class Adherent extends CommonObject
|
||||
$label.= '<br><b>' . $langs->trans('Name') . ':</b> ' . $this->getFullName($langs);
|
||||
$label.='</div>';
|
||||
|
||||
if (empty($option) || $option == 'card' || $option == 'category')
|
||||
{
|
||||
$url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id;
|
||||
}
|
||||
$url = DOL_URL_ROOT.'/adherents/card.php?rowid='.$this->id;
|
||||
if ($option == 'subscription')
|
||||
{
|
||||
$url = DOL_URL_ROOT.'/adherents/subscription.php?rowid='.$this->id;
|
||||
|
||||
@ -59,7 +59,7 @@ class AdherentType extends CommonObject
|
||||
public $note;
|
||||
/** @var bool Can vote*/
|
||||
public $vote;
|
||||
/** @var bool Email sent during validation */
|
||||
/** @var string Email sent during validation */
|
||||
public $mail_valid;
|
||||
/** @var array Array of members */
|
||||
public $members=array();
|
||||
@ -481,7 +481,7 @@ class AdherentType extends CommonObject
|
||||
|
||||
// Initialise parametres
|
||||
$this->id = 0;
|
||||
$this->ref = 0;
|
||||
$this->ref = 'MTSPEC';
|
||||
$this->specimen=1;
|
||||
|
||||
$this->label='MEMBERS TYPE SPECIMEN';
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
<?php
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
/* Copyright (C) 2016 Xebax Christy <xebax@wanadoo.fr>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* 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
|
||||
@ -19,6 +20,7 @@ use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/subscription.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
/**
|
||||
* API class for members
|
||||
@ -357,4 +359,38 @@ class Members extends DolibarrApi
|
||||
return $member->subscription($start_date, $amount, 0, '', $label, '', '', '', $end_date);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get categories for a member
|
||||
*
|
||||
* @param int $id ID of member
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
*
|
||||
* @return mixed
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$categories = new Categorie($this->db);
|
||||
|
||||
$result = $categories->getListForItem($id, 'member', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1749,7 +1749,7 @@ $db->close();
|
||||
* @param Object $obj If we show a particular record, obj is filled with record fields
|
||||
* @param string $tabname Name of SQL table
|
||||
* @param string $context 'add'=Output field for the "add form", 'edit'=Output field for the "edit form", 'hide'=Output field for the "add form" but we dont want it to be rendered
|
||||
* @return void
|
||||
* @return string '' or value of entity into table
|
||||
*/
|
||||
function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
{
|
||||
@ -1763,7 +1763,7 @@ function fieldList($fieldlist, $obj='', $tabname='', $context='')
|
||||
$formcompany = new FormCompany($db);
|
||||
if (! empty($conf->accounting->enabled)) $formaccounting = new FormAccounting($db);
|
||||
|
||||
$withentity=null;
|
||||
$withentity='';
|
||||
|
||||
foreach ($fieldlist as $field => $value)
|
||||
{
|
||||
|
||||
@ -136,6 +136,9 @@ class DolibarrApi
|
||||
unset($object->table_element_line);
|
||||
unset($object->picto);
|
||||
|
||||
unset($object->skip_update_total);
|
||||
unset($object->context);
|
||||
|
||||
// Remove the $oldcopy property because it is not supported by the JSON
|
||||
// encoder. The following error is generated when trying to serialize
|
||||
// it: "Error encoding/decoding JSON: Type is not supported"
|
||||
|
||||
@ -49,66 +49,85 @@ class Documents extends DolibarrApi
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return list of documents.
|
||||
* Returns a document. Note that, this API is similar to using the wrapper link "documents.php" to download
|
||||
* a file (used for internal HTML links of documents into application), but with no need to be into a logged session (no need to post the session cookie).
|
||||
*
|
||||
* @param string $module_part Name of module or area concerned by file download ('facture', ...)
|
||||
* @param string $ref Reference of object (This will define subdir automatically)
|
||||
* @param string $subdir NOT YET AVAILABLE : Subdirectory (Only if ref not provided)
|
||||
* @param string $original_file Relative path with filename, relative to modulepart (for example: IN201701-999/IN201701-999.pdf)
|
||||
* @param int $regeneratedoc If requested document is the main document of an object, setting this to 1 ask API to regenerate document before returning it (supported for some module_part only). It is no effect in other cases.
|
||||
* Also, note that setting this to 1 nead write access on object.
|
||||
* @return array List of documents
|
||||
*
|
||||
* @throws 500
|
||||
* @throws 501
|
||||
* @throws 400
|
||||
* @throws 401
|
||||
* @throws 200 OK
|
||||
* @throws 200
|
||||
*/
|
||||
public function index($module_part, $ref='', $subdir='') {
|
||||
global $conf;
|
||||
public function index($module_part, $original_file='', $regeneratedoc=0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
if (empty($module_part)) {
|
||||
throw new RestException(400, 'bad value for parameter modulepart');
|
||||
}
|
||||
if (empty($ref) && empty($subdir)) {
|
||||
if (empty($module_part)) {
|
||||
throw new RestException(400, 'bad value for parameter modulepart');
|
||||
}
|
||||
if (empty($original_file)) {
|
||||
throw new RestException(400, 'bad value for parameter ref or subdir');
|
||||
}
|
||||
if (empty($ref)) {
|
||||
throw new RestException(404, 'FeatureNotYetAvailable');
|
||||
}
|
||||
if (!DolibarrApiAccess::$user->rights->ecm->read) {
|
||||
throw new RestException(401);
|
||||
|
||||
//--- Finds and returns the document
|
||||
$entity=$conf->entity;
|
||||
|
||||
$check_access = dol_check_secure_access_document($module_part, $original_file, $entity, DolibarrApiAccess::$user, '', ($regeneratedoc ? 'write' : 'read'));
|
||||
$accessallowed = $check_access['accessallowed'];
|
||||
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
|
||||
$original_file = $check_access['original_file'];
|
||||
|
||||
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
|
||||
{
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!$accessallowed) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
// --- Generates the document
|
||||
if ($regeneratedoc)
|
||||
{
|
||||
$hidedetails = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DETAILS) ? 0 : 1;
|
||||
$hidedesc = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_DESC) ? 0 : 1;
|
||||
$hideref = empty($conf->global->MAIN_GENERATE_DOCUMENTS_HIDE_REF) ? 0 : 1;
|
||||
|
||||
if ($module_part == 'facture' || $module_part == 'invoice')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
|
||||
$this->invoice = new Facture($this->db);
|
||||
$result = $this->invoice->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Invoice not found');
|
||||
}
|
||||
$result = $this->invoice->generateDocument($this->invoice->modelpdf, $outputlangs, $hidedetails, $hidedesc, $hideref);
|
||||
if( $result <= 0 ) {
|
||||
throw new RestException(500, 'Error generating document');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$original_file = str_replace("../","/", $ref.'/'.$ref.'.pdf');
|
||||
$refname=basename(dirname($original_file)."/");
|
||||
$entity=$conf->entity;
|
||||
$filename = basename($original_file);
|
||||
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
|
||||
|
||||
$check_access = dol_check_secure_access_document($module_part,$original_file,$entity,DolibarrApiAccess::$user);
|
||||
$accessallowed = $check_access['accessallowed'];
|
||||
$sqlprotectagainstexternals = $check_access['sqlprotectagainstexternals'];
|
||||
$original_file = $check_access['original_file'];
|
||||
if (! file_exists($original_file_osencoded))
|
||||
{
|
||||
throw new RestException(404, 'File not found');
|
||||
}
|
||||
|
||||
if (preg_match('/\.\./',$original_file) || preg_match('/[<>|]/',$original_file))
|
||||
{
|
||||
throw new RestException(401);
|
||||
}
|
||||
if (!$accessallowed) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$filename = basename($original_file);
|
||||
$original_file_osencoded=dol_osencode($original_file); // New file name encoded in OS encoding charset
|
||||
|
||||
if (! file_exists($original_file_osencoded))
|
||||
{
|
||||
throw new RestException(404, 'File not found');
|
||||
}
|
||||
|
||||
$file_content=file_get_contents($original_file_osencoded);
|
||||
$file_content=file_get_contents($original_file_osencoded);
|
||||
return array('filename'=>$filename, 'content'=>base64_encode($file_content), 'encoding'=>'MIME base64 (base64_encode php function, http://php.net/manual/en/function.base64-encode.php)' );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Return a document.
|
||||
*
|
||||
@ -121,10 +140,10 @@ class Documents extends DolibarrApi
|
||||
public function get($id) {
|
||||
return array('note'=>'xxx');
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Push a file.
|
||||
* Push a file.
|
||||
* Test sample 1: { "filename": "mynewfile.txt", "modulepart": "facture", "ref": "FA1701-001", "subdir": "", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
|
||||
* Test sample 2: { "filename": "mynewfile.txt", "modulepart": "medias", "ref": "", "subdir": "mysubdir1/mysubdir2", "filecontent": "content text", "fileencoding": "", "overwriteifexists": "0" }.
|
||||
*
|
||||
@ -141,12 +160,12 @@ class Documents extends DolibarrApi
|
||||
public function post($filename, $modulepart, $ref='', $subdir='', $filecontent='', $fileencoding='', $overwriteifexists=0)
|
||||
{
|
||||
global $db, $conf;
|
||||
|
||||
|
||||
/*var_dump($modulepart);
|
||||
var_dump($filename);
|
||||
var_dump($filecontent);
|
||||
exit;*/
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
if (!DolibarrApiAccess::$user->rights->ecm->upload) {
|
||||
@ -170,7 +189,7 @@ class Documents extends DolibarrApi
|
||||
$object=new Facture($db);
|
||||
$result = $object->fetch('', $ref);
|
||||
}
|
||||
|
||||
|
||||
if (! ($object->id > 0))
|
||||
{
|
||||
throw new RestException(500, 'The object '.$modulepart." with ref '".$ref."' was not found.");
|
||||
@ -178,7 +197,7 @@ class Documents extends DolibarrApi
|
||||
|
||||
$tmp = dol_check_secure_access_document($modulepart, $tmpreldir.$object->ref, $entity, DolibarrApiAccess::$user, $ref, 'write');
|
||||
$upload_dir = $tmp['original_file'];
|
||||
|
||||
|
||||
if (empty($upload_dir) || $upload_dir == '/')
|
||||
{
|
||||
throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
|
||||
@ -187,7 +206,7 @@ class Documents extends DolibarrApi
|
||||
else
|
||||
{
|
||||
if ($modulepart == 'invoice') $modulepart ='facture';
|
||||
|
||||
|
||||
$tmp = dol_check_secure_access_document($modulepart, $subdir, $entity, DolibarrApiAccess::$user, '', 'write');
|
||||
$upload_dir = $tmp['original_file'];
|
||||
|
||||
@ -196,14 +215,14 @@ class Documents extends DolibarrApi
|
||||
throw new RestException(500, 'This value of modulepart does not support yet usage of ref. Check modulepart parameter or try to use subdir parameter instead of ref.');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
$upload_dir = dol_sanitizePathName($upload_dir);
|
||||
|
||||
|
||||
$destfile = $upload_dir . '/' . $original_file;
|
||||
$destfiletmp = DOL_DATA_ROOT.'/admin/temp/' . $original_file;
|
||||
dol_delete_file($destfiletmp);
|
||||
|
||||
|
||||
if (!dol_is_dir($upload_dir)) {
|
||||
throw new RestException(401,'Directory not exists : '.$upload_dir);
|
||||
}
|
||||
@ -212,7 +231,7 @@ class Documents extends DolibarrApi
|
||||
{
|
||||
throw new RestException(500, "File with name '".$original_file."' already exists.");
|
||||
}
|
||||
|
||||
|
||||
$fhandle = @fopen($destfiletmp, 'w');
|
||||
if ($fhandle)
|
||||
{
|
||||
@ -224,9 +243,9 @@ class Documents extends DolibarrApi
|
||||
{
|
||||
throw new RestException(500, "Failed to open file '".$destfiletmp."' for write");
|
||||
}
|
||||
|
||||
|
||||
$result = dol_move($destfiletmp, $destfile, 0, $overwriteifexists, 1);
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
@ -23,13 +23,13 @@
|
||||
/**
|
||||
* API class for categories
|
||||
*
|
||||
* @access protected
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class Categories extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'label',
|
||||
@ -44,7 +44,7 @@ class Categories extends DolibarrApi
|
||||
4 => 'contact',
|
||||
5 => 'account',
|
||||
);
|
||||
|
||||
|
||||
/**
|
||||
* @var Categorie $category {@type Categorie}
|
||||
*/
|
||||
@ -67,20 +67,20 @@ class Categories extends DolibarrApi
|
||||
*
|
||||
* @param int $id ID of category
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->category->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -90,7 +90,7 @@ class Categories extends DolibarrApi
|
||||
|
||||
/**
|
||||
* List categories
|
||||
*
|
||||
*
|
||||
* Get a list of categories
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
@ -105,13 +105,13 @@ class Categories extends DolibarrApi
|
||||
*/
|
||||
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type = '', $sqlfilters = '') {
|
||||
global $db, $conf;
|
||||
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$sql = "SELECT t.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as t";
|
||||
$sql.= ' WHERE t.entity IN ('.getEntity('category').')';
|
||||
@ -120,7 +120,7 @@ class Categories extends DolibarrApi
|
||||
$sql.= ' AND t.type='.array_search($type,Categories::$TYPES);
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
@ -129,93 +129,6 @@ class Categories extends DolibarrApi
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql.= $db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$i=0;
|
||||
$num = $db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $db->fetch_object($result);
|
||||
$category_static = new Categorie($db);
|
||||
if($category_static->fetch($obj->rowid)) {
|
||||
$obj_ret[] = $this->_cleanObjectDatas($category_static);
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$db->lasterror());
|
||||
}
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* List categories of an entity
|
||||
*
|
||||
* Note: This method is not directly exposed in the API, it is used
|
||||
* in the GET /xxx/{id}/categories requests.
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param int $item Id of the item to get categories for
|
||||
* @return array Array of category objects
|
||||
*
|
||||
* @access private
|
||||
*/
|
||||
function getListForItem($sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $type='customer', $item = 0) {
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
//if ($type == "") {
|
||||
//$type="product";
|
||||
//}
|
||||
$sub_type = $type;
|
||||
$subcol_name = "fk_".$type;
|
||||
if ($type=="customer" || $type=="supplier") {
|
||||
$sub_type="societe";
|
||||
$subcol_name="fk_soc";
|
||||
}
|
||||
if ($type=="contact") {
|
||||
$subcol_name="fk_socpeople";
|
||||
}
|
||||
$sql = "SELECT s.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
||||
$sql.= ' WHERE s.entity IN ('.getEntity('category').')';
|
||||
$sql.= ' AND s.type='.array_search($type,Categories::$TYPES);
|
||||
$sql.= ' AND s.rowid = sub.fk_categorie';
|
||||
$sql.= ' AND sub.'.$subcol_name.' = '.$item;
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $db->query($sql);
|
||||
$nbtotalofrecords = $db->num_rows($result);
|
||||
}
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
@ -250,13 +163,12 @@ class Categories extends DolibarrApi
|
||||
if( ! count($obj_ret)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create category object
|
||||
*
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of category
|
||||
*/
|
||||
@ -268,7 +180,7 @@ class Categories extends DolibarrApi
|
||||
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->category->$field = $value;
|
||||
}
|
||||
@ -280,22 +192,22 @@ class Categories extends DolibarrApi
|
||||
|
||||
/**
|
||||
* Update category
|
||||
*
|
||||
*
|
||||
* @param int $id Id of category to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
function put($id, $request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->categorie->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->category->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -304,13 +216,13 @@ class Categories extends DolibarrApi
|
||||
if ($field == 'id') continue;
|
||||
$this->category->$field = $value;
|
||||
}
|
||||
|
||||
|
||||
if($this->category->update(DolibarrApiAccess::$user))
|
||||
return $this->get ($id);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete category
|
||||
*
|
||||
@ -326,15 +238,15 @@ class Categories extends DolibarrApi
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'category not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('category',$this->category->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
|
||||
if (! $this->category->delete(DolibarrApiAccess::$user)) {
|
||||
throw new RestException(401,'error when delete category');
|
||||
}
|
||||
|
||||
|
||||
return array(
|
||||
'success' => array(
|
||||
'code' => 200,
|
||||
@ -342,8 +254,8 @@ class Categories extends DolibarrApi
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
@ -351,9 +263,9 @@ class Categories extends DolibarrApi
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object) {
|
||||
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
|
||||
// Remove fields not relevent to categories
|
||||
unset($object->country);
|
||||
unset($object->country_id);
|
||||
@ -394,16 +306,16 @@ class Categories extends DolibarrApi
|
||||
unset($object->fk_project);
|
||||
unset($object->note);
|
||||
unset($object->statut);
|
||||
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
*
|
||||
* @param array|null $data Data to validate
|
||||
* @return array
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate($data)
|
||||
|
||||
@ -879,6 +879,100 @@ class Categorie extends CommonObject
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* List categories of an element id
|
||||
*
|
||||
* @param int $id Id of element
|
||||
* @param string $type Type of category ('member', 'customer', 'supplier', 'product', 'contact')
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @return array Array of categories
|
||||
*/
|
||||
function getListForItem($id, $type='customer', $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
global $conf;
|
||||
|
||||
$categories = array();
|
||||
|
||||
$sub_type = $type;
|
||||
$subcol_name = "fk_".$type;
|
||||
if ($type=="customer" || $type=="supplier") {
|
||||
$sub_type="societe";
|
||||
$subcol_name="fk_soc";
|
||||
}
|
||||
if ($type=="contact") {
|
||||
$subcol_name="fk_socpeople";
|
||||
}
|
||||
$sql = "SELECT s.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."categorie as s";
|
||||
$sql.= " , ".MAIN_DB_PREFIX."categorie_".$sub_type." as sub ";
|
||||
$sql.= ' WHERE s.entity IN ('.getEntity('category').')';
|
||||
$sql.= ' AND s.type='.array_search($type, self::$MAP_ID_TO_CODE);
|
||||
$sql.= ' AND s.rowid = sub.fk_categorie';
|
||||
$sql.= ' AND sub.'.$subcol_name.' = '.$id;
|
||||
|
||||
$nbtotalofrecords = '';
|
||||
if (empty($conf->global->MAIN_DISABLE_FULL_SCANLIST))
|
||||
{
|
||||
$result = $this->db->query($sql);
|
||||
$nbtotalofrecords = $this->db->num_rows($result);
|
||||
}
|
||||
|
||||
$sql.= $this->db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
{
|
||||
$page = 0;
|
||||
}
|
||||
$offset = $limit * $page;
|
||||
|
||||
$sql.= $this->db->plimit($limit + 1, $offset);
|
||||
}
|
||||
|
||||
$result = $this->db->query($sql);
|
||||
if ($result)
|
||||
{
|
||||
$i=0;
|
||||
$num = $this->db->num_rows($result);
|
||||
$min = min($num, ($limit <= 0 ? $num : $limit));
|
||||
while ($i < $min)
|
||||
{
|
||||
$obj = $this->db->fetch_object($result);
|
||||
$category_static = new Categorie($this->db);
|
||||
if ($category_static->fetch($obj->rowid))
|
||||
{
|
||||
$categories[$i]['id'] = $category_static->id;
|
||||
$categories[$i]['fk_parent'] = $category_static->fk_parent;
|
||||
$categories[$i]['label'] = $category_static->label;
|
||||
$categories[$i]['description'] = $category_static->description;
|
||||
$categories[$i]['color'] = $category_static->color;
|
||||
$categories[$i]['socid'] = $category_static->socid;
|
||||
$categories[$i]['visible'] = $category_static->visible;
|
||||
$categories[$i]['type'] = $category_static->type;
|
||||
$categories[$i]['entity'] = $category_static->entity;
|
||||
$categories[$i]['array_options'] = $category_static->array_options;
|
||||
|
||||
// multilangs
|
||||
if (! empty($conf->global->MAIN_MULTILANGS)) {
|
||||
$categories[$i]['multilangs'] = $category_static->multilangs;
|
||||
}
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
$this->error = $this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
if ( ! count($categories)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return $categories;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return childs of a category
|
||||
*
|
||||
|
||||
@ -319,7 +319,7 @@ else
|
||||
|
||||
|
||||
// List of products or services (type is type of category)
|
||||
if ($object->type == Categorie::TYPE_PRODUCT)
|
||||
if ($type == Categorie::TYPE_PRODUCT)
|
||||
{
|
||||
$prods = $object->getObjectsInCateg("product");
|
||||
if ($prods < 0)
|
||||
@ -391,7 +391,7 @@ if ($object->type == Categorie::TYPE_PRODUCT)
|
||||
}
|
||||
}
|
||||
|
||||
if ($object->type == Categorie::TYPE_SUPPLIER)
|
||||
if ($type == Categorie::TYPE_SUPPLIER)
|
||||
{
|
||||
$socs = $object->getObjectsInCateg("supplier");
|
||||
if ($socs < 0)
|
||||
@ -440,7 +440,7 @@ if ($object->type == Categorie::TYPE_SUPPLIER)
|
||||
}
|
||||
}
|
||||
|
||||
if($object->type == Categorie::TYPE_CUSTOMER)
|
||||
if($type == Categorie::TYPE_CUSTOMER)
|
||||
{
|
||||
$socs = $object->getObjectsInCateg("customer");
|
||||
if ($socs < 0)
|
||||
@ -494,7 +494,7 @@ if($object->type == Categorie::TYPE_CUSTOMER)
|
||||
}
|
||||
|
||||
// List of members
|
||||
if ($object->type == Categorie::TYPE_MEMBER)
|
||||
if ($type == Categorie::TYPE_MEMBER)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/adherents/class/adherent.class.php';
|
||||
|
||||
@ -547,7 +547,7 @@ if ($object->type == Categorie::TYPE_MEMBER)
|
||||
}
|
||||
|
||||
// Categorie contact
|
||||
if($object->type == Categorie::TYPE_CONTACT)
|
||||
if ($type == Categorie::TYPE_CONTACT)
|
||||
{
|
||||
$contacts = $object->getObjectsInCateg("contact");
|
||||
if ($contacts < 0)
|
||||
@ -600,7 +600,7 @@ if($object->type == Categorie::TYPE_CONTACT)
|
||||
}
|
||||
|
||||
// List of accounts
|
||||
if ($object->type == Categorie::TYPE_ACCOUNT)
|
||||
if ($type == Categorie::TYPE_ACCOUNT)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php';
|
||||
|
||||
@ -653,7 +653,7 @@ if ($object->type == Categorie::TYPE_ACCOUNT)
|
||||
}
|
||||
|
||||
// List of Project
|
||||
if ($object->type == Categorie::TYPE_PROJECT)
|
||||
if ($type == Categorie::TYPE_PROJECT)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
|
||||
|
||||
@ -357,7 +357,7 @@ if ($resql)
|
||||
//$param='month='.$monthshown.'&year='.$year;
|
||||
$hourminsec='100000';
|
||||
$link = '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create&datep='.sprintf("%04d%02d%02d",$tmpforcreatebutton['year'],$tmpforcreatebutton['mon'],$tmpforcreatebutton['mday']).$hourminsec.'&backtopage='.urlencode($_SERVER["PHP_SELF"].($newparam?'?'.$newparam:'')).'">';
|
||||
$link.= $langs->trans("NewAction");
|
||||
$link.= $langs->trans("AddAction");
|
||||
$link.= '</a>';
|
||||
}
|
||||
|
||||
@ -372,9 +372,9 @@ if ($resql)
|
||||
print '<tr class="liste_titre_filter">';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre"><input type="text" name="search_title" value="'.$search_title.'"></td>';
|
||||
print '<td class="liste_titre"></td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
print $form->select_date($datestart, 'datestart', 0, 0, 1, '', 1, 0, 1);
|
||||
print '</td>';
|
||||
print '<td class="liste_titre" align="center">';
|
||||
@ -396,9 +396,9 @@ if ($resql)
|
||||
print '<tr class="liste_titre">';
|
||||
print_liste_field_titre("Ref",$_SERVER["PHP_SELF"],"a.id",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("ActionsOwnedByShort",$_SERVER["PHP_SELF"],"",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
//if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Type",$_SERVER["PHP_SELF"],"c.libelle",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("Label",$_SERVER["PHP_SELF"],"a.label",$param,"","",$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateStart",$_SERVER["PHP_SELF"],"a.datep",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("DateEnd",$_SERVER["PHP_SELF"],"a.datep2",$param,'','align="center"',$sortfield,$sortorder);
|
||||
print_liste_field_titre("ThirdParty",$_SERVER["PHP_SELF"],"s.nom",$param,"","",$sortfield,$sortorder);
|
||||
@ -452,11 +452,6 @@ if ($resql)
|
||||
else print ' ';
|
||||
print '</td>';
|
||||
|
||||
// Label
|
||||
print '<td class="tdoverflowmax300">';
|
||||
print $actionstatic->label;
|
||||
print '</td>';
|
||||
|
||||
// Type
|
||||
print '<td>';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
@ -475,6 +470,11 @@ if ($resql)
|
||||
print dol_trunc($labeltype,28);
|
||||
print '</td>';
|
||||
|
||||
// Label
|
||||
print '<td class="tdoverflowmax300">';
|
||||
print $actionstatic->label;
|
||||
print '</td>';
|
||||
|
||||
// Start date
|
||||
print '<td align="center" class="nowrap">';
|
||||
print dol_print_date($db->jdate($obj->dp),"dayhour");
|
||||
|
||||
@ -116,7 +116,7 @@ if ($resql)
|
||||
print '<input type="hidden" name="sortorder" value="'.$sortorder.'">';
|
||||
print '<input type="hidden" name="page" value="'.$page.'">';
|
||||
|
||||
print_barre_liste($langs->trans("Actions"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
|
||||
print_barre_liste($langs->trans("EventReports"), $page, $_SERVER["PHP_SELF"], $param, $sortfield, $sortorder, '', $num, $nbtotalofrecords, 'title_agenda', 0, '', '', $limit);
|
||||
|
||||
$moreforfilter='';
|
||||
|
||||
|
||||
@ -278,7 +278,7 @@ class Proposals extends DolibarrApi
|
||||
$request_data->fk_unit,
|
||||
$this->element,
|
||||
$request_data->id,
|
||||
$request_data->pu_ht_devise,
|
||||
$request_data->multicurrency_subprice,
|
||||
$request_data->fk_remise_except
|
||||
);
|
||||
|
||||
@ -316,26 +316,27 @@ class Proposals extends DolibarrApi
|
||||
$request_data = (object) $request_data;
|
||||
$updateRes = $this->propal->updateline(
|
||||
$lineid,
|
||||
$request_data->desc,
|
||||
$request_data->subprice,
|
||||
$request_data->qty,
|
||||
$request_data->remise_percent,
|
||||
$request_data->tva_tx,
|
||||
$request_data->localtax1_tx,
|
||||
$request_data->localtax2_tx,
|
||||
'HT',
|
||||
$request_data->desc,
|
||||
'HT',
|
||||
$request_data->info_bits,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->product_type,
|
||||
$request_data->fk_parent_line,
|
||||
0,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->special_code,
|
||||
$request_data->fk_parent_line,
|
||||
0,
|
||||
$request_data->fk_fournprice,
|
||||
$request_data->pa_ht,
|
||||
$request_data->label,
|
||||
$request_data->product_type,
|
||||
$request_data->date_start,
|
||||
$request_data->date_end,
|
||||
$request_data->array_options,
|
||||
$request_data->fk_unit
|
||||
$request_data->fk_unit,
|
||||
$request_data->multicurrency_subprice
|
||||
);
|
||||
|
||||
if ($updateRes > 0) {
|
||||
@ -508,4 +509,23 @@ class Proposals extends DolibarrApi
|
||||
}
|
||||
return $propal;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
* @param object $object Object to clean
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object) {
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
unset($object->name);
|
||||
unset($object->lastname);
|
||||
unset($object->firstname);
|
||||
unset($object->civility_id);
|
||||
unset($object->address);
|
||||
|
||||
return $object;
|
||||
}
|
||||
}
|
||||
|
||||
@ -639,6 +639,7 @@ class Propal extends CommonObject
|
||||
$pa_ht=price2num($pa_ht);
|
||||
if (empty($qty) && empty($special_code)) $special_code=3; // Set option tag
|
||||
if (! empty($qty) && $special_code == 3) $special_code=0; // Remove option tag
|
||||
if (empty($type)) $type=0;
|
||||
|
||||
if ($this->statut == self::STATUS_DRAFT)
|
||||
{
|
||||
|
||||
@ -213,7 +213,7 @@ if (empty($reshook))
|
||||
// TODO Move this into mass action include
|
||||
if ($massaction == 'confirm_createbills') {
|
||||
|
||||
$orders = GETPOST('toselect');
|
||||
$orders = GETPOST('toselect','array');
|
||||
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
|
||||
$validate_invoices = GETPOST('valdate_invoices', 'int');
|
||||
|
||||
@ -224,13 +224,13 @@ if (empty($reshook))
|
||||
|
||||
$db->begin();
|
||||
|
||||
foreach($orders as $id_order) {
|
||||
|
||||
foreach($orders as $id_order)
|
||||
{
|
||||
$cmd = new Commande($db);
|
||||
if($cmd->fetch($id_order) <= 0) continue;
|
||||
if ($cmd->fetch($id_order) <= 0) continue;
|
||||
|
||||
$object = new Facture($db);
|
||||
if(!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
||||
if (!empty($createbills_onebythird) && !empty($TFactThird[$cmd->socid])) $object = $TFactThird[$cmd->socid]; // If option "one bill per third" is set, we use already created order.
|
||||
else {
|
||||
|
||||
$object->socid = $cmd->socid;
|
||||
@ -252,12 +252,10 @@ if (empty($reshook))
|
||||
$res = $object->create($user);
|
||||
|
||||
if($res > 0) $nb_bills_created++;
|
||||
|
||||
}
|
||||
|
||||
if($object->id > 0) {
|
||||
|
||||
$db->begin();
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
|
||||
$sql.= "fk_source";
|
||||
$sql.= ", sourcetype";
|
||||
@ -270,115 +268,113 @@ if (empty($reshook))
|
||||
$sql.= ", '".$object->element."'";
|
||||
$sql.= ")";
|
||||
|
||||
if ($db->query($sql))
|
||||
if (! $db->query($sql))
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$error++;
|
||||
}
|
||||
|
||||
$lines = $cmd->lines;
|
||||
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
|
||||
if (! $error)
|
||||
{
|
||||
$cmd->fetch_lines();
|
||||
$lines = $cmd->lines;
|
||||
$lines = $cmd->lines;
|
||||
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
|
||||
{
|
||||
$cmd->fetch_lines();
|
||||
$lines = $cmd->lines;
|
||||
}
|
||||
|
||||
$fk_parent_line=0;
|
||||
$num=count($lines);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
if ($lines[$i]->subprice < 0)
|
||||
{
|
||||
// Negative line, we create a discount line
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fk_soc=$object->socid;
|
||||
$discount->amount_ht=abs($lines[$i]->total_ht);
|
||||
$discount->amount_tva=abs($lines[$i]->total_tva);
|
||||
$discount->amount_ttc=abs($lines[$i]->total_ttc);
|
||||
$discount->tva_tx=$lines[$i]->tva_tx;
|
||||
$discount->fk_user=$user->id;
|
||||
$discount->description=$desc;
|
||||
$discountid=$discount->create($user);
|
||||
if ($discountid > 0)
|
||||
{
|
||||
$result=$object->insert_discount($discountid);
|
||||
//$result=$discount->link_to_invoice($lineid,$id);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Positive line
|
||||
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
|
||||
// Date start
|
||||
$date_start=false;
|
||||
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
|
||||
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
|
||||
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
|
||||
//Date end
|
||||
$date_end=false;
|
||||
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
|
||||
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
$lines[$i]->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$product_type,
|
||||
$ii,
|
||||
$lines[$i]->special_code,
|
||||
$object->origin,
|
||||
$lines[$i]->rowid,
|
||||
$fk_parent_line,
|
||||
$lines[$i]->fk_fournprice,
|
||||
$lines[$i]->pa_ht,
|
||||
$lines[$i]->label
|
||||
);
|
||||
if ($result > 0)
|
||||
{
|
||||
$lineid=$result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineid=0;
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fk_parent_line=0;
|
||||
$num=count($lines);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
if ($lines[$i]->subprice < 0)
|
||||
{
|
||||
// Negative line, we create a discount line
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fk_soc=$object->socid;
|
||||
$discount->amount_ht=abs($lines[$i]->total_ht);
|
||||
$discount->amount_tva=abs($lines[$i]->total_tva);
|
||||
$discount->amount_ttc=abs($lines[$i]->total_ttc);
|
||||
$discount->tva_tx=$lines[$i]->tva_tx;
|
||||
$discount->fk_user=$user->id;
|
||||
$discount->description=$desc;
|
||||
$discountid=$discount->create($user);
|
||||
if ($discountid > 0)
|
||||
{
|
||||
$result=$object->insert_discount($discountid);
|
||||
//$result=$discount->link_to_invoice($lineid,$id);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Positive line
|
||||
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
|
||||
// Date start
|
||||
$date_start=false;
|
||||
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
|
||||
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
|
||||
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
|
||||
//Date end
|
||||
$date_end=false;
|
||||
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
|
||||
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
$lines[$i]->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$product_type,
|
||||
$ii,
|
||||
$lines[$i]->special_code,
|
||||
$object->origin,
|
||||
$lines[$i]->rowid,
|
||||
$fk_parent_line,
|
||||
$lines[$i]->fk_fournprice,
|
||||
$lines[$i]->pa_ht,
|
||||
$lines[$i]->label
|
||||
);
|
||||
if ($result > 0)
|
||||
{
|
||||
$lineid=$result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineid=0;
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//$cmd->classifyBilled($user); // Disabled. This behavior must be set or not using the workflow module.
|
||||
@ -391,27 +387,29 @@ if (empty($reshook))
|
||||
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
|
||||
$toselect = array();
|
||||
|
||||
if(!empty($validate_invoices)) {
|
||||
|
||||
if (! $error && $validate_invoices)
|
||||
{
|
||||
$massaction = $action = 'builddoc';
|
||||
foreach($TAllFact as &$object)
|
||||
{
|
||||
$result = $object->validate($user);
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
break;
|
||||
}
|
||||
|
||||
foreach($TAllFact as &$object) {
|
||||
$object->validate($user);
|
||||
$toselect[] = $object->id; // For builddoc action
|
||||
$id = $object->id; // For builddoc action
|
||||
|
||||
// Fac builddoc
|
||||
$donotredirect = 1;
|
||||
$upload_dir = $conf->facture->dir_output;
|
||||
$permissioncreate=$user->rights->facture->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
}
|
||||
|
||||
$objectclass='Facture';
|
||||
$objectlabel='Invoice';
|
||||
$permtoread = $user->rights->facture->lire;
|
||||
$permtodelete = $user->rights->facture->supprimer;
|
||||
$uploaddir = $conf->facture->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
|
||||
$massaction = $action = 'confirm_createbills';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
|
||||
@ -2097,6 +2097,10 @@ class Facture extends CommonInvoice
|
||||
$error=0;
|
||||
dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse);
|
||||
|
||||
// Force to have object complete for checks
|
||||
$this->fetch_thirdparty();
|
||||
$this->fetch_lines();
|
||||
|
||||
// Check parameters
|
||||
if (! $this->brouillon)
|
||||
{
|
||||
@ -2119,9 +2123,6 @@ class Facture extends CommonInvoice
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$this->fetch_thirdparty();
|
||||
$this->fetch_lines();
|
||||
|
||||
// Check parameters
|
||||
if ($this->type == self::TYPE_REPLACEMENT) // si facture de remplacement
|
||||
{
|
||||
|
||||
@ -308,7 +308,7 @@ if ($action == 'create')
|
||||
print '<td class="titlefieldcreate fieldrequired">';
|
||||
print $langs->trans("Label");
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="34" name="label" class="flat" value="'.GETPOST('label').'"></td>';
|
||||
print '<td><input type="text" size="34" name="label" class="flat" value="'.dol_escape_htmltag(GETPOST('label','alpha')).'" autofocus></td>';
|
||||
print '</tr>';
|
||||
print '<tr>';
|
||||
|
||||
@ -317,7 +317,7 @@ if ($action == 'create')
|
||||
print $langs->trans("Type");
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode")?GETPOST("actioncode"):'','actioncode',1);
|
||||
$formsocialcontrib->select_type_socialcontrib(GETPOST("actioncode",'alpha')?GETPOST("actioncode",'alpha'):'','actioncode',1);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
@ -336,7 +336,7 @@ if ($action == 'create')
|
||||
print '<td class="fieldrequired">';
|
||||
print $langs->trans("Amount");
|
||||
print '</td>';
|
||||
print '<td><input type="text" size="6" name="amount" class="flat" value="'.GETPOST('amount').'"></td>';
|
||||
print '<td><input type="text" size="6" name="amount" class="flat" value="'.dol_escape_htmltag(GETPOST('amount','alpha')).'"></td>';
|
||||
print '</tr>';
|
||||
|
||||
// Project
|
||||
|
||||
@ -257,30 +257,33 @@ else
|
||||
}
|
||||
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
//print '<div class="tabsAction">';
|
||||
//print '</div>';
|
||||
|
||||
|
||||
$morehtmlcenter='';
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
|
||||
$morehtmlcenter.= '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
$morehtmlcenter.= '<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
$param='&id='.$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("TasksHistoryForThisContact"),'','');
|
||||
print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
|
||||
|
||||
// List of all actions
|
||||
$filters=array();
|
||||
|
||||
@ -91,10 +91,13 @@ if ($action == 'builddoc' && $permissioncreate)
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($langs->trans("FileGenerated"), null);
|
||||
if (empty($donotredirect)) // This is se when include is done by bulk action "Bill Orders"
|
||||
{
|
||||
setEventMessages($langs->trans("FileGenerated"), null);
|
||||
|
||||
header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc');
|
||||
exit;
|
||||
header('Location: '.$_SERVER['REQUEST_URI'].'#builddoc');
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
76
htdocs/core/actions_comments.inc.php
Normal file
76
htdocs/core/actions_comments.inc.php
Normal file
@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/* Copyright (C) 2011-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*
|
||||
* $elementype must be defined.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/core/actions_comments.inc.php
|
||||
* \brief Code for actions on comments pages
|
||||
*/
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
|
||||
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
$comment = new Comment($db);
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcomment')
|
||||
{
|
||||
$description = GETPOST('comment_description', 'none');
|
||||
if (!empty($description))
|
||||
{
|
||||
$comment->description = $description;
|
||||
$comment->datec = time();
|
||||
$comment->fk_element = GETPOST('id','int');
|
||||
$comment->element_type = GETPOST('comment_element_type','alpha');
|
||||
$comment->fk_user_author = $user->id;
|
||||
$comment->entity = $conf->entity;
|
||||
if ($comment->create($user) > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("CommentAdded"), null, 'mesgs');
|
||||
header('Location: '.$varpage.'?id='.$id.($withproject?'&withproject=1':''));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($comment->error, $comment->errors,'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($action == 'deletecomment')
|
||||
{
|
||||
if ($comment->fetch($idcomment) >= 0)
|
||||
{
|
||||
if ($comment->delete($user) > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs');
|
||||
header('Location: '.$varpage.'?id='.$id.($withproject?'&withproject=1':''));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($comment->error, $comment->errors,'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
324
htdocs/core/class/comment.class.php
Normal file
324
htdocs/core/class/comment.class.php
Normal file
@ -0,0 +1,324 @@
|
||||
<?php
|
||||
/**
|
||||
* Class to manage comment
|
||||
*/
|
||||
class Comment extends CommonObject
|
||||
{
|
||||
public $element='comment'; //!< Id that identify managed objects
|
||||
public $table_element='comment'; //!< Name of table without prefix where object is stored
|
||||
|
||||
var $fk_element;
|
||||
var $element_type;
|
||||
|
||||
var $description;
|
||||
|
||||
var $tms;
|
||||
|
||||
var $datec;
|
||||
|
||||
var $fk_user_author;
|
||||
|
||||
var $entity;
|
||||
|
||||
var $import_key;
|
||||
|
||||
public $oldcopy;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create into database
|
||||
*
|
||||
* @param User $user User that create
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
function create($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."comment (";
|
||||
$sql.= "description";
|
||||
$sql.= ", datec";
|
||||
$sql.= ", fk_element";
|
||||
$sql.= ", element_type";
|
||||
$sql.= ", fk_user_author";
|
||||
$sql.= ", entity";
|
||||
$sql.= ", import_key";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->db->escape($this->description)."'";
|
||||
$sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null');
|
||||
$sql.= ", '".(isset($this->fk_element)?$this->fk_element:"null")."'";
|
||||
$sql.= ", '".$this->db->escape($this->element_type)."'";
|
||||
$sql.= ", '".(isset($this->fk_user_author)?$this->fk_user_author:"null")."'";
|
||||
$sql.= ", ".(!empty($this->entity)?$this->entity:'1');
|
||||
$sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
|
||||
$sql.= ")";
|
||||
|
||||
//var_dump($this->db);
|
||||
//echo $sql;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment");
|
||||
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TASK_COMMENT_CREATE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load object in memory from database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param int $ref ref object
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
function fetch($id, $ref='')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql.= " c.rowid,";
|
||||
$sql.= " c.description,";
|
||||
$sql.= " c.datec,";
|
||||
$sql.= " c.tms,";
|
||||
$sql.= " c.fk_element,";
|
||||
$sql.= " c.element_type,";
|
||||
$sql.= " c.fk_user_author,";
|
||||
$sql.= " c.entity,";
|
||||
$sql.= " c.import_key";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."comment as c";
|
||||
$sql.= " WHERE c.rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_rows = $this->db->num_rows($resql);
|
||||
|
||||
if ($num_rows)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->description = $obj->description;
|
||||
$this->element_type = $obj->element_type;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->tms = $obj->tms;
|
||||
$this->fk_user_author = $obj->fk_user_author;
|
||||
$this->fk_element = $obj->fk_element;
|
||||
$this->entity = $obj->entity;
|
||||
$this->import_key = $obj->import_key;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
if ($num_rows) return 1;
|
||||
else return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update database
|
||||
*
|
||||
* @param User $user User that modify
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function update(User $user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_element)) $this->fk_project=(int) trim($this->fk_element);
|
||||
if (isset($this->fk_user_author)) $this->fk_user_author=(int) trim($this->fk_user_author);
|
||||
if (isset($this->description)) $this->description=trim($this->description);
|
||||
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET";
|
||||
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
||||
$sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').",";
|
||||
$sql.= " fk_element=".(isset($this->fk_element)?$this->fk_element:"null").",";
|
||||
$sql.= " element_type='".$this->db->escape($this->element_type)."',";
|
||||
$sql.= " fk_user_author=".(isset($this->fk_user_author)?$this->fk_user_author:"null").",";
|
||||
$sql.= " entity=".(!empty($this->entity)?$this->entity:'1').",";
|
||||
$sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TASK_COMMENT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete task from database
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."comment";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TASK_COMMENT_DELETE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}else{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load comments linked with current task
|
||||
*
|
||||
* @param string $element_type Element type
|
||||
* @param int $fk_element Id of element
|
||||
* @return array Comment array
|
||||
*/
|
||||
public static function fetchAllFor($element_type, $fk_element)
|
||||
{
|
||||
global $db,$conf;
|
||||
$TComments = array();
|
||||
if(!empty($element_type) && !empty($fk_element)) {
|
||||
$sql = "SELECT";
|
||||
$sql.= " c.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."comment as c";
|
||||
$sql.= " WHERE c.fk_element = ".$fk_element;
|
||||
$sql.= " AND c.element_type = '".$element_type."'";
|
||||
$sql.= " AND c.entity = ".$conf->entity;
|
||||
$sql.= " ORDER BY c.tms DESC";
|
||||
|
||||
dol_syslog("Comment::fetchAllFor", LOG_DEBUG);
|
||||
$resql=$db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_rows = $db->num_rows($resql);
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
while($obj = $db->fetch_object($resql))
|
||||
{
|
||||
$comment = new self($db);
|
||||
$comment->fetch($obj->rowid);
|
||||
$TComments[] = $comment;
|
||||
}
|
||||
}
|
||||
$db->free($resql);
|
||||
}
|
||||
}
|
||||
return $TComments;
|
||||
}
|
||||
}
|
||||
@ -309,6 +309,12 @@ abstract class CommonObject
|
||||
*/
|
||||
public $lines;
|
||||
|
||||
/**
|
||||
* @var mixed Contains comments
|
||||
* @see fetchComments()
|
||||
*/
|
||||
public $comments=array();
|
||||
|
||||
/**
|
||||
* @var int
|
||||
* @see setIncoterms()
|
||||
@ -4638,13 +4644,19 @@ abstract class CommonObject
|
||||
{
|
||||
$out .= '<tr '.$class.$csstyle.' class="'.$this->element.'_extras_'.$key.'">';
|
||||
}
|
||||
// Convert date into timestamp format
|
||||
// Convert date into timestamp format (value in memory must be a timestamp)
|
||||
if (in_array($extrafields->attribute_type[$key],array('date','datetime')))
|
||||
{
|
||||
$value = isset($_POST["options_".$key])?dol_mktime($_POST["options_".$key."hour"], $_POST["options_".$key."min"], 0, $_POST["options_".$key."month"], $_POST["options_".$key."day"], $_POST["options_".$key."year"]):$this->db->jdate($this->array_options['options_'.$key]);
|
||||
}
|
||||
// Convert float submited string into real php numeric (value in memory must be a php numeric)
|
||||
if (in_array($extrafields->attribute_type[$key],array('price','double')))
|
||||
{
|
||||
$value = isset($_POST["options_".$key])?price2num($_POST["options_".$key]):$this->array_options['options_'.$key];
|
||||
}
|
||||
|
||||
$labeltoshow = $langs->trans($label);
|
||||
|
||||
if($extrafields->attribute_required[$key])
|
||||
{
|
||||
$labeltoshow = '<span'.($mode != 'view' ? ' class="fieldrequired"':'').'>'.$labeltoshow.'</span>';
|
||||
@ -5289,4 +5301,27 @@ abstract class CommonObject
|
||||
// TODO...
|
||||
}
|
||||
|
||||
/**
|
||||
* Load comments linked with current task
|
||||
* @return boolean 1 if ok
|
||||
*/
|
||||
public function fetchComments()
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/comment.class.php';
|
||||
|
||||
$comment = new Comment($this->db);
|
||||
$this->comments = Comment::fetchAllFor($this->element, $this->id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return nb comments already posted
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getNbComments()
|
||||
{
|
||||
return count($this->comments);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -804,7 +804,7 @@ class ExtraFields
|
||||
* Return HTML string to put an input field into a page
|
||||
*
|
||||
* @param string $key Key of attribute
|
||||
* @param string $value Preselected value to show (for date type it must be in timestamp format)
|
||||
* @param string $value Preselected value to show (for date type it must be in timestamp format, for amount or price it must be a php numeric value)
|
||||
* @param string $moreparam To add more parametes on html input tag
|
||||
* @param string $keyprefix Prefix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
* @param string $keysuffix Suffix string to add into name and id of field (can be used to avoid duplicate names)
|
||||
@ -927,11 +927,14 @@ class ExtraFields
|
||||
}
|
||||
elseif ($type == 'price')
|
||||
{
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.price2num($value).'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
|
||||
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
||||
$value=price($value);
|
||||
}
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> '.$langs->getCurrencySymbol($conf->currency);
|
||||
}
|
||||
elseif ($type == 'double')
|
||||
{
|
||||
if (!empty($value)) {
|
||||
if (!empty($value)) { // $value in memory is a php numeric, we format it into user number format.
|
||||
$value=price($value);
|
||||
}
|
||||
$out='<input type="text" class="flat '.$showsize.' maxwidthonsmartphone" name="'.$keysuffix.'options_'.$key.$keyprefix.'" value="'.$value.'" '.($moreparam?$moreparam:'').'> ';
|
||||
|
||||
@ -157,9 +157,10 @@ class FormActions
|
||||
* @param string $morecss More css on table
|
||||
* @param int $max Max number of record
|
||||
* @param string $moreparambacktopage More param for the backtopage
|
||||
* @param string $morehtmlright More html text on right of title line
|
||||
* @return int <0 if KO, >=0 if OK
|
||||
*/
|
||||
function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='')
|
||||
function showactions($object, $typeelement, $socid=0, $forceshowtitle=0, $morecss='listactions', $max=0, $moreparambacktopage='', $morehtmlright='')
|
||||
{
|
||||
global $langs,$conf,$user;
|
||||
global $bc;
|
||||
@ -196,7 +197,7 @@ class FormActions
|
||||
$buttontoaddnewevent.= '</a>';
|
||||
|
||||
print '<!-- formactions->showactions -->'."\n";
|
||||
print load_fiche_titre($title, $buttontoaddnewevent, '');
|
||||
print load_fiche_titre($title, $morehtmlright, '', 0, 0, '', $buttontoaddnewevent);
|
||||
|
||||
$page=0; $param='';
|
||||
|
||||
@ -206,10 +207,10 @@ class FormActions
|
||||
print '<table class="noborder'.($morecss?' '.$morecss:'').'" width="100%">';
|
||||
print '<tr class="liste_titre">';
|
||||
print getTitleFieldOfList('Ref', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('Action', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('By', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('Type', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('Action', 0, $_SERVER["PHP_SELF"], '', $page, $param, '', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('Date', 0, $_SERVER["PHP_SELF"], 'a.datep', $page, $param, 'align="center"', $sortfield, $sortorder, '', 1);
|
||||
print getTitleFieldOfList('', 0, $_SERVER["PHP_SELF"], '', $page, $param, 'align="right"', $sortfield, $sortorder, '', 1);
|
||||
print '</tr>';
|
||||
print "\n";
|
||||
@ -228,8 +229,14 @@ class FormActions
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$ref.'</td>';
|
||||
print '<td>'.$label.'</td>';
|
||||
print '<td>';
|
||||
if (! empty($action->userownerid))
|
||||
{
|
||||
$userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched
|
||||
print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', '');
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
if ($action->type_picto) print img_picto('', $action->type_picto);
|
||||
@ -242,6 +249,7 @@ class FormActions
|
||||
}
|
||||
print $action->type;
|
||||
print '</td>';
|
||||
print '<td>'.$label.'</td>';
|
||||
print '<td align="center">'.dol_print_date($action->datep,'dayhour');
|
||||
if ($action->datef)
|
||||
{
|
||||
@ -254,13 +262,6 @@ class FormActions
|
||||
else print '-'.dol_print_date($action->datef,'dayhour');
|
||||
}
|
||||
print '</td>';
|
||||
print '<td>';
|
||||
if (! empty($action->userownerid))
|
||||
{
|
||||
$userstatic->fetch($action->userownerid); // TODO Introduce a cache on users fetched
|
||||
print $userstatic->getNomUrl(-1, '', 0, 0, 16, 0, '', '');
|
||||
}
|
||||
print '</td>';
|
||||
print '<td align="right">';
|
||||
if (! empty($action->author->id))
|
||||
{
|
||||
|
||||
@ -63,18 +63,15 @@ function ajax_autocompleter($selected, $htmlname, $url, $urloption='', $minLengt
|
||||
var autoselect = '.$autoselect.';
|
||||
var options = '.json_encode($ajaxoptions).';
|
||||
|
||||
/* Remove product id before select another product use keyup instead of change to avoid loosing the product id. This is needed only for select of predefined product */
|
||||
/* TODO Check if we can remove this */
|
||||
$("input#search_'.$htmlname.'").keydown(function() {
|
||||
$("#'.$htmlname.'").val("");
|
||||
/* Remove selected id as soon as we type or delete a char (it means old selection is wrong). Use keyup/down instead of change to avoid loosing the product id. This is needed only for select of predefined product */
|
||||
$("input#search_'.$htmlname.'").keydown(function(e) {
|
||||
if (e.keyCode != 9) /* If not "Tab" key */
|
||||
{
|
||||
console.log("Clear id previously selected for field '.$htmlname.'");
|
||||
$("#'.$htmlname.'").val("");
|
||||
}
|
||||
});
|
||||
|
||||
/* I disable this. A call to trigger is already done later into the select action of the autocomplete code
|
||||
$("input#search_'.$htmlname.'").change(function() {
|
||||
console.log("Call the change trigger on input '.$htmlname.' because of a change on search_'.$htmlname.' was triggered");
|
||||
$("#'.$htmlname.'").trigger("change");
|
||||
});*/
|
||||
|
||||
// Check options for secondary actions when keyup
|
||||
$("input#search_'.$htmlname.'").keyup(function() {
|
||||
if ($(this).val().length == 0)
|
||||
|
||||
@ -1287,11 +1287,11 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
}
|
||||
$out.='<td class="liste_titre"></td>';
|
||||
$out.='<td class="liste_titre"></td>';
|
||||
$out.='<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters['search_agenda_label'].'"></td>';
|
||||
$out.='<td class="liste_titre"></td>';
|
||||
$out.='<td class="liste_titre">';
|
||||
$out.=$formactions->select_type_actions($actioncode, "actioncode", '', empty($conf->global->AGENDA_USE_EVENT_TYPE)?1:-1, 0, 0, 1);
|
||||
$out.='</td>';
|
||||
$out.='<td class="liste_titre maxwidth100onsmartphone"><input type="text" class="maxwidth100onsmartphone" name="search_agenda_label" value="'.$filters['search_agenda_label'].'"></td>';
|
||||
$out.='<td class="liste_titre"></td>';
|
||||
$out.='<td class="liste_titre"></td>';
|
||||
$out.='<td class="liste_titre"></td>';
|
||||
$out.='<td class="liste_titre"></td>';
|
||||
@ -1316,9 +1316,9 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
}
|
||||
$out.=getTitleFieldOfList($langs->trans("Ref"), 0, $_SERVER["PHP_SELF"], 'a.id', '', $param, '', $sortfield, $sortorder);
|
||||
$out.=getTitleFieldOfList($langs->trans("Owner"));
|
||||
$out.=getTitleFieldOfList($langs->trans("Type"));
|
||||
$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("Type"));
|
||||
$out.=getTitleFieldOfList('');
|
||||
$out.=getTitleFieldOfList('');
|
||||
$out.=getTitleFieldOfList($langs->trans("Status"), 0, $_SERVER["PHP_SELF"], 'a.percent', '', $param, 'align="center"', $sortfield, $sortorder);
|
||||
@ -1353,6 +1353,25 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
$out.=$userstatic->getNomUrl(-1);
|
||||
$out.='</td>';
|
||||
|
||||
// Type
|
||||
$out.='<td>';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
if ($histo[$key]['apicto']) $out.=img_picto('', $histo[$key]['apicto']);
|
||||
else {
|
||||
if ($histo[$key]['acode'] == 'AC_TEL') $out.=img_picto('', 'object_phoning').' ';
|
||||
if ($histo[$key]['acode'] == 'AC_FAX') $out.=img_picto('', 'object_phoning_fax').' ';
|
||||
if ($histo[$key]['acode'] == 'AC_EMAIL') $out.=img_picto('', 'object_email').' ';
|
||||
}
|
||||
$out.=$actionstatic->type;
|
||||
}
|
||||
else {
|
||||
$typelabel = $actionstatic->type;
|
||||
if ($histo[$key]['acode'] != 'AC_OTH_AUTO') $typelabel = $langs->trans("ActionAC_MANUAL");
|
||||
$out.=$typelabel;
|
||||
}
|
||||
$out.='</td>';
|
||||
|
||||
// Title
|
||||
$out.='<td>';
|
||||
if (isset($histo[$key]['type']) && $histo[$key]['type']=='action')
|
||||
@ -1392,25 +1411,6 @@ function show_actions_done($conf, $langs, $db, $filterobj, $objcon='', $noprint=
|
||||
if ($late) $out.=img_warning($langs->trans("Late")).' ';
|
||||
$out.="</td>\n";
|
||||
|
||||
// Type
|
||||
$out.='<td>';
|
||||
if (! empty($conf->global->AGENDA_USE_EVENT_TYPE))
|
||||
{
|
||||
if ($histo[$key]['apicto']) $out.=img_picto('', $histo[$key]['apicto']);
|
||||
else {
|
||||
if ($histo[$key]['acode'] == 'AC_TEL') $out.=img_picto('', 'object_phoning').' ';
|
||||
if ($histo[$key]['acode'] == 'AC_FAX') $out.=img_picto('', 'object_phoning_fax').' ';
|
||||
if ($histo[$key]['acode'] == 'AC_EMAIL') $out.=img_picto('', 'object_email').' ';
|
||||
}
|
||||
$out.=$actionstatic->type;
|
||||
}
|
||||
else {
|
||||
$typelabel = $actionstatic->type;
|
||||
if ($histo[$key]['acode'] != 'AC_OTH_AUTO') $typelabel = $langs->trans("ActionAC_MANUAL");
|
||||
$out.=$typelabel;
|
||||
}
|
||||
$out.='</td>';
|
||||
|
||||
// Title of event
|
||||
//$out.='<td>'.dol_trunc($histo[$key]['note'], 40).'</td>';
|
||||
|
||||
|
||||
@ -3540,10 +3540,11 @@ function print_fiche_titre($title, $mesg='', $picto='title_generic.png', $pictoi
|
||||
* @param int $pictoisfullpath 1=Icon name is a full absolute url of image
|
||||
* @param int $id To force an id on html objects
|
||||
* @param string $morecssontable More css on table
|
||||
* @param string $morehtmlcenter Added message to show on center
|
||||
* @return string
|
||||
* @see print_barre_liste
|
||||
*/
|
||||
function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='')
|
||||
function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png', $pictoisfullpath=0, $id=0, $morecssontable='', $morehtmlcenter='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
@ -3558,6 +3559,10 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
|
||||
$return.= '<td class="nobordernopadding" valign="middle">';
|
||||
$return.= '<div class="titre">'.$titre.'</div>';
|
||||
$return.= '</td>';
|
||||
if (dol_strlen($morehtmlcenter))
|
||||
{
|
||||
$return.= '<td class="nobordernopadding" align="center" valign="middle">'.$morehtmlcenter.'</td>';
|
||||
}
|
||||
if (dol_strlen($morehtmlright))
|
||||
{
|
||||
$return.= '<td class="nobordernopadding titre_right" align="right" valign="middle">'.$morehtmlright.'</td>';
|
||||
@ -3585,9 +3590,10 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
|
||||
* @param string $morecss More css to the table
|
||||
* @param int $limit Max number of lines (-1 = use default, 0 = no limit, > 0 = limit).
|
||||
* @param int $hideselectlimit Force to hide select limit
|
||||
* @param int $hidenavigation Force to hide all navigation tools
|
||||
* @return void
|
||||
*/
|
||||
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0)
|
||||
function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $sortorder='', $center='', $num=-1, $totalnboflines='', $picto='title_generic.png', $pictoisfullpath=0, $morehtml='', $morecss='', $limit=-1, $hideselectlimit=0, $hidenavigation=0)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
@ -3781,7 +3787,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
* @param string $rate Rate value to format ('19.6', '19,6', '19.6%', '19,6%', '19.6 (CODEX)', ...)
|
||||
* @param boolean $addpercent Add a percent % sign in output
|
||||
* @param int $info_bits Miscellaneous information on vat (0=Default, 1=French NPR vat)
|
||||
* @param int $usestarfornpr 1=Use '*' for NPR vat rate intead of MAIN_LABEL_MENTION_NPR
|
||||
* @param int $usestarfornpr -1=Never show, 0 or 1=Use '*' for NPR vat rates
|
||||
* @return string String with formated amounts ('19,6' or '19,6%' or '8.5% (NPR)' or '8.5% *' or '19,6 (CODEX)')
|
||||
*/
|
||||
function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
|
||||
@ -3811,7 +3817,7 @@ function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
|
||||
// TODO Split on / and output with a price2num to have clean numbers without ton of 000.
|
||||
$ret=$rate.($addpercent?'%':'');
|
||||
}
|
||||
if ($info_bits & 1) $ret.=' *';
|
||||
if (($info_bits & 1) && $usestarfornpr >= 0) $ret.=' *';
|
||||
$ret.=$morelabel;
|
||||
return $ret;
|
||||
}
|
||||
@ -6372,7 +6378,7 @@ function dolExplodeIntoArray($string, $delimiter = ';', $kv = '=')
|
||||
|
||||
|
||||
/**
|
||||
* Set focus onto field with selector
|
||||
* Set focus onto field with selector (similar behaviour of 'autofocus' HTML5 tag)
|
||||
*
|
||||
* @param string $selector Selector ('#id' or 'input[name="ref"]') to use to find the HTML input field that must get the autofocus. You must use a CSS selector, so unique id preceding with the '#' char.
|
||||
* @return string HTML code to set focus
|
||||
|
||||
@ -1491,14 +1491,14 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0)
|
||||
{
|
||||
$tmpresult='';
|
||||
|
||||
$tmpresult.=vatrate($object->lines[$i]->tva_tx, 1, $object->lines[$i]->info_bits, 1);
|
||||
$tmpresult.=vatrate($object->lines[$i]->tva_tx, 0, $object->lines[$i]->info_bits, -1);
|
||||
if (empty($conf->global->MAIN_PDF_MAIN_HIDE_SECOND_TAX))
|
||||
{
|
||||
if ($object->lines[$i]->total_localtax1 != 0)
|
||||
{
|
||||
if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/';
|
||||
else $tmpresult='';
|
||||
$tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx),1);
|
||||
$tmpresult.=vatrate(abs($object->lines[$i]->localtax1_tx), 0);
|
||||
}
|
||||
}
|
||||
if (empty($conf->global->MAIN_PDF_MAIN_HIDE_THIRD_TAX))
|
||||
@ -1507,9 +1507,10 @@ function pdf_getlinevatrate($object,$i,$outputlangs,$hidedetails=0)
|
||||
{
|
||||
if (preg_replace('/[\s0%]/','',$tmpresult)) $tmpresult.='/';
|
||||
else $tmpresult='';
|
||||
$tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx),1);
|
||||
$tmpresult.=vatrate(abs($object->lines[$i]->localtax2_tx), 0);
|
||||
}
|
||||
}
|
||||
$tmpresult.= '%';
|
||||
|
||||
$result.=$tmpresult;
|
||||
}
|
||||
@ -1820,6 +1821,8 @@ function pdf_getlineremisepercent($object,$i,$outputlangs,$hidedetails=0)
|
||||
*/
|
||||
function pdf_getlineprogress($object, $i, $outputlangs, $hidedetails = 0, $hookmanager = null)
|
||||
{
|
||||
if (empty($hookmanager)) global $hookmanager;
|
||||
|
||||
$reshook=0;
|
||||
$result='';
|
||||
//if (is_object($hookmanager) && ( (isset($object->lines[$i]->product_type) && $object->lines[$i]->product_type == 9 && ! empty($object->lines[$i]->special_code)) || ! empty($object->lines[$i]->fk_parent_line) ) )
|
||||
|
||||
@ -67,6 +67,7 @@ function project_prepare_head($object)
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'project');
|
||||
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$nbNote = 0;
|
||||
@ -110,6 +111,17 @@ function project_prepare_head($object)
|
||||
$h++;
|
||||
}
|
||||
|
||||
// Manage discussion
|
||||
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_PROJECT))
|
||||
{
|
||||
$nbComments = $object->getNbComments();
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/comment.php?id='.$object->id;
|
||||
$head[$h][1] = $langs->trans("CommentLink");
|
||||
if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
|
||||
$head[$h][2] = 'project_comment';
|
||||
$h++;
|
||||
}
|
||||
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/info.php?id='.$object->id;
|
||||
$head[$h][1].= $langs->trans("Events");
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
@ -176,17 +188,6 @@ function task_prepare_head($object)
|
||||
// $this->tabs = array('entity:-tabname); to remove a tab
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'task');
|
||||
|
||||
// Manage discussion
|
||||
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK))
|
||||
{
|
||||
$nbComments= $object->getNbComments();
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
|
||||
$head[$h][1] = $langs->trans("TaskCommentLinks");
|
||||
if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
|
||||
$head[$h][2] = 'task_comment';
|
||||
$h++;
|
||||
}
|
||||
|
||||
if (empty($conf->global->MAIN_DISABLE_NOTES_TAB))
|
||||
{
|
||||
$nbNote = 0;
|
||||
@ -210,6 +211,17 @@ function task_prepare_head($object)
|
||||
$head[$h][2] = 'task_document';
|
||||
$h++;
|
||||
|
||||
// Manage discussion
|
||||
if (!empty($conf->global->PROJECT_ALLOW_COMMENT_ON_TASK))
|
||||
{
|
||||
$nbComments = $object->getNbComments();
|
||||
$head[$h][0] = DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$object->id.(GETPOST('withproject')?'&withproject=1':'');
|
||||
$head[$h][1] = $langs->trans("CommentLink");
|
||||
if ($nbComments > 0) $head[$h][1].= ' <span class="badge">'.$nbComments.'</span>';
|
||||
$head[$h][2] = 'task_comment';
|
||||
$h++;
|
||||
}
|
||||
|
||||
complete_head_from_modules($conf,$langs,$object,$head,$h,'task','remove');
|
||||
|
||||
return $head;
|
||||
|
||||
@ -138,7 +138,7 @@ function check_user_password_ldap($usertotest,$passwordtotest,$entitytotest)
|
||||
$ldap->searchUser=$ldapuserattr."=".$usertotest.",".$ldapdn; // Default dn (will work if LDAP accept a dn with login value inside)
|
||||
// But if LDAP need a dn with name like "cn=Jhon Bloggs,ou=People,dc=foo,dc=com", previous part must have been executed to have
|
||||
// dn detected into ldapUserDN.
|
||||
if ($resultFetchLdapUser AND !empty($ldap->ldapUserDN)) $ldap->searchUser = $ldap->ldapUserDN;
|
||||
if ($resultFetchLdapUser && !empty($ldap->ldapUserDN)) $ldap->searchUser = $ldap->ldapUserDN;
|
||||
$ldap->searchPassword=$passwordtotest;
|
||||
|
||||
// Test with this->seachUser and this->searchPassword
|
||||
|
||||
@ -328,14 +328,14 @@ class DolibarrModules // Can not be abstract, because we need to insta
|
||||
public $langfiles;
|
||||
|
||||
/**
|
||||
* @var string[] Array of warnings to show when we activate the module
|
||||
* @var array<string,string> Array of warnings to show when we activate the module
|
||||
*
|
||||
* array('always'='text') or array('FR'='text')
|
||||
*/
|
||||
public $warnings_activation;
|
||||
|
||||
/**
|
||||
* @var string[] Array of warnings to show when we activate an external module
|
||||
* @var array<string,string> Array of warnings to show when we activate an external module
|
||||
*
|
||||
* array('always'='text') or array('FR'='text')
|
||||
*/
|
||||
|
||||
@ -140,7 +140,7 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->posxtva=112;
|
||||
$this->posxtva=110;
|
||||
$this->posxup=126;
|
||||
$this->posxqty=145;
|
||||
}
|
||||
@ -431,8 +431,8 @@ class pdf_einstein extends ModelePDFCommandes
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
|
||||
{
|
||||
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetXY($this->posxtva, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
|
||||
$pdf->SetXY($this->posxtva-5, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
|
||||
}
|
||||
|
||||
// Unit price before discount
|
||||
|
||||
@ -136,27 +136,27 @@ class html_cerfafr extends ModeleDon
|
||||
else $paymentmode = '';
|
||||
|
||||
if ($don->modepaiementid==7){
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox" disabled="true" checked="checked"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
|
||||
}
|
||||
else if ($don->modepaiementid==4){
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox" checked="checked"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
|
||||
}
|
||||
else if ($don->modepaiementid==2 OR $don->modepaiementid==3 OR $don->modepaiementid==6){
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
|
||||
else if ($don->modepaiementid==2 || $don->modepaiementid==3 || $don->modepaiementid==6){
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox" checked="checked"> Virement, prélèvement, carte bancaire</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
|
||||
$ModePaiement = '<td width="25%"><input type="checkbox"> Remise d\'espèces</td><td width="25%"><input type="checkbox"> Chèque</td><td width="50%"><input type="checkbox"> Virement, prélèvement, carte bancaire</td>';
|
||||
}
|
||||
|
||||
/*
|
||||
if (empty($don->societe))
|
||||
{
|
||||
$CodeDon = '<td width="33%"><input type="checkbox" disabled="true" checked="checked" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 885-0 V bis A du CGI</td>';
|
||||
$CodeDon = '<td width="33%"><input type="checkbox" disabled="true" checked="checked" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 885-0 V bis A du CGI</td>';
|
||||
}
|
||||
else
|
||||
{
|
||||
$CodeDon = '<td width="33%"><input type="checkbox" disabled="true" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" checked="checked" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 885-0 V bis A du CGI</td>';
|
||||
$CodeDon = '<td width="33%"><input type="checkbox" disabled="true" > 200 du CGI</td><td width="33%"><input type="checkbox" disabled="true" checked="checked" > 238 bis du CGI</td><td width="33%"><input type="checkbox" disabled="true" > 885-0 V bis A du CGI</td>';
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
@ -125,7 +125,7 @@ class pdf_crabe extends ModelePDFFactures
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->posxtva=112;
|
||||
$this->posxtva=110;
|
||||
$this->posxup=126;
|
||||
$this->posxqty=145;
|
||||
}
|
||||
@ -496,8 +496,8 @@ class pdf_crabe extends ModelePDFFactures
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
|
||||
{
|
||||
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetXY($this->posxtva, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
|
||||
$pdf->SetXY($this->posxtva-5, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
|
||||
}
|
||||
|
||||
// Unit price before discount
|
||||
|
||||
@ -114,7 +114,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->posxtva=112;
|
||||
$this->posxtva=110;
|
||||
$this->posxup=126;
|
||||
$this->posxqty=145;
|
||||
}
|
||||
@ -505,8 +505,8 @@ class pdf_azur extends ModelePDFPropales
|
||||
if (empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT) && empty($conf->global->MAIN_GENERATE_DOCUMENTS_WITHOUT_VAT_COLUMN))
|
||||
{
|
||||
$vat_rate = pdf_getlinevatrate($object, $i, $outputlangs, $hidedetails);
|
||||
$pdf->SetXY($this->posxtva, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva-0.8, 3, $vat_rate, 0, 'R');
|
||||
$pdf->SetXY($this->posxtva-5, $curY);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva+4, 3, $vat_rate, 0, 'R');
|
||||
}
|
||||
|
||||
// Unit price before discount
|
||||
@ -1312,6 +1312,7 @@ class pdf_azur extends ModelePDFPropales
|
||||
$pdf->line($this->posxtva-1, $tab_top, $this->posxtva-1, $tab_top + $tab_height);
|
||||
if (empty($hidetop))
|
||||
{
|
||||
// Not do -3 and +3 instead of -1 -1 to have more space for text 'Sales tax'
|
||||
$pdf->SetXY($this->posxtva-3, $tab_top+1);
|
||||
$pdf->MultiCell($this->posxup-$this->posxtva+3,2, $outputlangs->transnoentities("VAT"),'','C');
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
<?php
|
||||
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
|
||||
/* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2014 Teddy Andreotti <125155@supinfo.com>
|
||||
* Copyright (C) 2017 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* 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
|
||||
@ -98,7 +99,10 @@ class modGeneratePassPerso extends ModeleGenPassword
|
||||
$this->Spe = str_replace($this->Ambi,"",$this->Spe);
|
||||
}
|
||||
|
||||
$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe);
|
||||
$pattern = $this->Min . (! empty($this->NbMaj)?$this->Maj:'') . (! empty($this->NbNum)?$this->Nb:'') . (! empty($this->NbSpe)?$this->Spe:'');
|
||||
$this->All = str_shuffle($pattern);
|
||||
|
||||
//$this->All = str_shuffle($this->Maj. $this->Min. $this->Nb. $this->Spe);
|
||||
//$this->All = $this->Maj. $this->Min. $this->Nb. $this->Spe;
|
||||
//$this->All = $this->Spe;
|
||||
|
||||
|
||||
107
htdocs/core/tpl/bloc_comment.tpl.php
Normal file
107
htdocs/core/tpl/bloc_comment.tpl.php
Normal file
@ -0,0 +1,107 @@
|
||||
<?php
|
||||
// Require
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
|
||||
// Vars
|
||||
$userstatic = new User($db);
|
||||
$varpage=empty($contextpage)?$_SERVER["PHP_SELF"]:$contextpage;
|
||||
|
||||
|
||||
// Add comment
|
||||
print '<br>';
|
||||
print '<div id="comment">';
|
||||
print '<form method="POST" action="'.$varpage.'?id='.$object->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcomment">';
|
||||
print '<input type="hidden" name="id" value="'.$object->id.'">';
|
||||
print '<input type="hidden" name="comment_element_type" value="'.$object->element.'">';
|
||||
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
|
||||
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="25%">'.$langs->trans("Comments").'</td>';
|
||||
print '<td width="25%"></td>';
|
||||
print '<td width="25%"></td>';
|
||||
print '<td width="25%"></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
|
||||
// Description
|
||||
print '<td colspan="3">';
|
||||
|
||||
$desc = GETPOST('comment_description');
|
||||
|
||||
$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%');
|
||||
print $doleditor->Create(1);
|
||||
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>';
|
||||
print '</table></form>';
|
||||
|
||||
// List of comments
|
||||
if (!empty($object->comments))
|
||||
{
|
||||
// Default color for current user
|
||||
$TColors = array($user->id => array('bgcolor'=>'efefef','color'=>'555'));
|
||||
$first = true;
|
||||
foreach($object->comments as $comment)
|
||||
{
|
||||
$fk_user = $comment->fk_user_author;
|
||||
$userstatic->fetch($fk_user);
|
||||
|
||||
if(empty($TColors[$fk_user])) {
|
||||
$bgcolor = random_color(180,240);
|
||||
if(!empty($userstatic->color)) {
|
||||
$bgcolor = $userstatic->color;
|
||||
}
|
||||
$color = (colorIsLight($bgcolor))?'555':'fff';
|
||||
$TColors[$fk_user] = array('bgcolor'=>$bgcolor,'color'=>$color);
|
||||
}
|
||||
print '<div class="width100p" style="color:#'.$TColors[$fk_user]['color'].'">';
|
||||
if ($fk_user != $user->id) {
|
||||
print '<div class="width25p float"> </div>';
|
||||
}
|
||||
|
||||
print '<div class="width75p float comment comment-table" style="background-color:#'.$TColors[$fk_user]['bgcolor'].'">';
|
||||
print '<div class="comment-info comment-cell">';
|
||||
if (! empty($user->photo))
|
||||
{
|
||||
print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'<br/>';
|
||||
}
|
||||
print $langs->trans('User').' : '.$userstatic->getNomUrl().'<br/>';
|
||||
print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec');
|
||||
print '</div>'; // End comment-info
|
||||
|
||||
print '<div class="comment-cell comment-right">';
|
||||
print '<div class="comment-table width100p">';
|
||||
print '<div class="comment-description comment-cell">';
|
||||
print $comment->description;
|
||||
print '</div>'; // End comment-description
|
||||
if(($first && $fk_user == $user->id) || $user->admin == 1) {
|
||||
print '<a class="comment-delete comment-cell" href="'.$varpage.'?action=deletecomment&id='.$id.'&withproject=1&idcomment='.$comment->id.'" title="'.$langs->trans('Delete').'">';
|
||||
print img_picto('', 'delete.png');
|
||||
print '</a>';
|
||||
}
|
||||
print '</div>'; // End comment-table
|
||||
print '</div>'; // End comment-right
|
||||
print '</div>'; // End comment
|
||||
|
||||
if($fk_user == $user->id) {
|
||||
print '<div class="width25p float"> </div>';
|
||||
}
|
||||
print '<div class="clearboth"></div>';
|
||||
print '</div>'; // end 100p
|
||||
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print '</div>';
|
||||
@ -27,6 +27,7 @@
|
||||
* \remarks Call of this wrapper is made with URL:
|
||||
* document.php?modulepart=repfichierconcerne&file=relativepathoffile
|
||||
* document.php?modulepart=logs&file=dolibarr.log
|
||||
* document.php?modulepart=logs&hashp=sharekey
|
||||
*/
|
||||
|
||||
define('NOTOKENRENEWAL',1); // Disables token renewal
|
||||
|
||||
@ -82,10 +82,9 @@ class EcmFiles //extends CommonObject
|
||||
/**
|
||||
* Create object into database
|
||||
*
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
*
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
* @param User $user User that creates
|
||||
* @param bool $notrigger false=launch triggers after, true=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
public function create(User $user, $notrigger = false)
|
||||
{
|
||||
@ -144,8 +143,8 @@ class EcmFiles //extends CommonObject
|
||||
if (empty($this->date_c)) $this->date_c = dol_now();
|
||||
|
||||
// If ref not defined
|
||||
if (empty($ref)) $ref = dol_hash($this->filepath.'/'.$this->filename, 3);
|
||||
|
||||
$ref = dol_hash($this->filepath.'/'.$this->filename, 3);
|
||||
if (! empty($this->ref)) $ref=$this->ref;
|
||||
|
||||
$maxposition=0;
|
||||
if (empty($this->position)) // Get max used
|
||||
|
||||
@ -1487,14 +1487,14 @@ class Expedition extends CommonObject
|
||||
* Return clicable link of object (with eventually picto)
|
||||
*
|
||||
* @param int $withpicto Add picto into link
|
||||
* @param int $option Where point the link
|
||||
* @param string $option Where the link point to
|
||||
* @param int $max Max length to show
|
||||
* @param int $short Use short labels
|
||||
* @param int $notooltip 1=No tooltip
|
||||
* @param int $save_lastsearch_value -1=Auto, 0=No save of lastsearch_values when clicking, 1=Save lastsearch_values whenclicking
|
||||
* @return string String with URL
|
||||
*/
|
||||
function getNomUrl($withpicto=0, $option=0, $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
|
||||
function getNomUrl($withpicto=0, $option='', $max=0, $short=0, $notooltip=0, $save_lastsearch_value=-1)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
/* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2004-2016 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2005-2015 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
* Copyright (C) 2011-2013 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2011-2017 Juanjo Menent <jmenent@2byte.es>
|
||||
* Copyright (C) 2013 Florian Henry <florian.henry@open-concept.pro>
|
||||
* Copyright (C) 2014-2015 Ferran Marcet <fmarcet@2byte.es>
|
||||
* Copyright (C) 2014-2015 Charlie Benke <charlies@patas-monkey.com>
|
||||
@ -743,7 +743,8 @@ if (empty($reshook))
|
||||
$parameters=array('id'=>$object->id);
|
||||
$reshook=$hookmanager->executeHooks('insertExtraFields',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks
|
||||
if (empty($reshook))
|
||||
{ $result=$object->updateExtraField($_POST["attribute"]);
|
||||
{
|
||||
$result=$object->insertExtraFields();
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
|
||||
@ -663,7 +663,7 @@ class Fichinter extends CommonObject
|
||||
*/
|
||||
function getNomUrl($withpicto=0, $option='', $notooltip=0, $save_lastsearch_value=-1)
|
||||
{
|
||||
global $langs;
|
||||
global $conf, $langs;
|
||||
|
||||
$result='';
|
||||
|
||||
@ -674,13 +674,13 @@ class Fichinter extends CommonObject
|
||||
$picto='intervention';
|
||||
$url = DOL_URL_ROOT.'/fichinter/card.php?id='.$this->id;
|
||||
|
||||
//if ($option !== 'nolink')
|
||||
//{
|
||||
// Add param to save lastsearch_values or not
|
||||
if ($option !== 'nolink')
|
||||
{
|
||||
// Add param to save lastsearch_values or not
|
||||
$add_save_lastsearch_values=($save_lastsearch_value == 1 ? 1 : 0);
|
||||
if ($save_lastsearch_value == -1 && preg_match('/list\.php/',$_SERVER["PHP_SELF"])) $add_save_lastsearch_values=1;
|
||||
if ($add_save_lastsearch_values) $url.='&save_lastsearch_values=1';
|
||||
//}
|
||||
}
|
||||
|
||||
$linkclose='';
|
||||
if (empty($notooltip))
|
||||
|
||||
@ -1090,6 +1090,10 @@ class FactureFournisseur extends CommonInvoice
|
||||
$error=0;
|
||||
dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number.', idwarehouse='.$idwarehouse);
|
||||
|
||||
// Force to have object complete for checks
|
||||
$this->fetch_thirdparty();
|
||||
$this->fetch_lines();
|
||||
|
||||
// Check parameters
|
||||
if ($this->statut > self::STATUS_DRAFT) // This is to avoid to validate twice (avoid errors on logs and stock management)
|
||||
{
|
||||
@ -2550,15 +2554,10 @@ class SupplierInvoiceLine extends CommonObjectLine
|
||||
}
|
||||
|
||||
// Clean parameters
|
||||
if (empty($this->tva_tx)) {
|
||||
$this->tva_tx = 0;
|
||||
}
|
||||
if (empty($this->localtax1_tx)) {
|
||||
$this->localtax1_tx = 0;
|
||||
}
|
||||
if (empty($this->localtax2_tx)) {
|
||||
$this->localtax2_tx = 0;
|
||||
}
|
||||
if (empty($this->remise_percent)) $this->remise_percent = 0;
|
||||
if (empty($this->tva_tx)) $this->tva_tx = 0;
|
||||
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
|
||||
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
|
||||
@ -232,7 +232,7 @@ if (empty($reshook))
|
||||
// TODO Move this into mass action include
|
||||
if ($massaction == 'confirm_createbills')
|
||||
{
|
||||
$orders = GETPOST('toselect');
|
||||
$orders = GETPOST('toselect','array');
|
||||
$createbills_onebythird = GETPOST('createbills_onebythird', 'int');
|
||||
$validate_invoices = GETPOST('valdate_invoices', 'int');
|
||||
|
||||
@ -274,9 +274,8 @@ if (empty($reshook))
|
||||
|
||||
}
|
||||
|
||||
if($object->id > 0) {
|
||||
|
||||
$db->begin();
|
||||
if ($object->id > 0)
|
||||
{
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_element (";
|
||||
$sql.= "fk_source";
|
||||
$sql.= ", sourcetype";
|
||||
@ -289,118 +288,116 @@ if (empty($reshook))
|
||||
$sql.= ", '".$object->element."'";
|
||||
$sql.= ")";
|
||||
|
||||
if ($db->query($sql))
|
||||
if (! $db->query($sql))
|
||||
{
|
||||
$db->commit();
|
||||
}
|
||||
else
|
||||
{
|
||||
$db->rollback();
|
||||
$erorr++;
|
||||
}
|
||||
|
||||
$lines = $cmd->lines;
|
||||
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
|
||||
if (! $error)
|
||||
{
|
||||
$cmd->fetch_lines();
|
||||
$lines = $cmd->lines;
|
||||
$lines = $cmd->lines;
|
||||
if (empty($lines) && method_exists($cmd, 'fetch_lines'))
|
||||
{
|
||||
$cmd->fetch_lines();
|
||||
$lines = $cmd->lines;
|
||||
}
|
||||
|
||||
$fk_parent_line=0;
|
||||
$num=count($lines);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
if ($lines[$i]->subprice < 0)
|
||||
{
|
||||
// Negative line, we create a discount line
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fk_soc=$object->socid;
|
||||
$discount->amount_ht=abs($lines[$i]->total_ht);
|
||||
$discount->amount_tva=abs($lines[$i]->total_tva);
|
||||
$discount->amount_ttc=abs($lines[$i]->total_ttc);
|
||||
$discount->tva_tx=$lines[$i]->tva_tx;
|
||||
$discount->fk_user=$user->id;
|
||||
$discount->description=$desc;
|
||||
$discountid=$discount->create($user);
|
||||
if ($discountid > 0)
|
||||
{
|
||||
$result=$object->insert_discount($discountid);
|
||||
//$result=$discount->link_to_invoice($lineid,$id);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Positive line
|
||||
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
|
||||
// Date start
|
||||
$date_start=false;
|
||||
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
|
||||
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
|
||||
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
|
||||
//Date end
|
||||
$date_end=false;
|
||||
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
|
||||
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
$lines[$i]->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$product_type,
|
||||
$ii,
|
||||
$lines[$i]->special_code,
|
||||
$object->origin,
|
||||
$lines[$i]->rowid,
|
||||
$fk_parent_line,
|
||||
$lines[$i]->fk_fournprice,
|
||||
$lines[$i]->pa_ht,
|
||||
$lines[$i]->label
|
||||
);
|
||||
if ($result > 0)
|
||||
{
|
||||
$lineid=$result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineid=0;
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$fk_parent_line=0;
|
||||
$num=count($lines);
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$desc=($lines[$i]->desc?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
if ($lines[$i]->subprice < 0)
|
||||
{
|
||||
// Negative line, we create a discount line
|
||||
$discount = new DiscountAbsolute($db);
|
||||
$discount->fk_soc=$object->socid;
|
||||
$discount->amount_ht=abs($lines[$i]->total_ht);
|
||||
$discount->amount_tva=abs($lines[$i]->total_tva);
|
||||
$discount->amount_ttc=abs($lines[$i]->total_ttc);
|
||||
$discount->tva_tx=$lines[$i]->tva_tx;
|
||||
$discount->fk_user=$user->id;
|
||||
$discount->description=$desc;
|
||||
$discountid=$discount->create($user);
|
||||
if ($discountid > 0)
|
||||
{
|
||||
$result=$object->insert_discount($discountid);
|
||||
//$result=$discount->link_to_invoice($lineid,$id);
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($discount->error, $discount->errors, 'errors');
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Positive line
|
||||
$product_type=($lines[$i]->product_type?$lines[$i]->product_type:0);
|
||||
// Date start
|
||||
$date_start=false;
|
||||
if ($lines[$i]->date_debut_prevue) $date_start=$lines[$i]->date_debut_prevue;
|
||||
if ($lines[$i]->date_debut_reel) $date_start=$lines[$i]->date_debut_reel;
|
||||
if ($lines[$i]->date_start) $date_start=$lines[$i]->date_start;
|
||||
//Date end
|
||||
$date_end=false;
|
||||
if ($lines[$i]->date_fin_prevue) $date_end=$lines[$i]->date_fin_prevue;
|
||||
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
$result = $object->addline(
|
||||
$desc,
|
||||
$lines[$i]->subprice,
|
||||
$lines[$i]->qty,
|
||||
$lines[$i]->tva_tx,
|
||||
$lines[$i]->localtax1_tx,
|
||||
$lines[$i]->localtax2_tx,
|
||||
$lines[$i]->fk_product,
|
||||
$lines[$i]->remise_percent,
|
||||
$date_start,
|
||||
$date_end,
|
||||
0,
|
||||
$lines[$i]->info_bits,
|
||||
$lines[$i]->fk_remise_except,
|
||||
'HT',
|
||||
0,
|
||||
$product_type,
|
||||
$ii,
|
||||
$lines[$i]->special_code,
|
||||
$object->origin,
|
||||
$lines[$i]->rowid,
|
||||
$fk_parent_line,
|
||||
$lines[$i]->fk_fournprice,
|
||||
$lines[$i]->pa_ht,
|
||||
$lines[$i]->label
|
||||
);
|
||||
if ($result > 0)
|
||||
{
|
||||
$lineid=$result;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lineid=0;
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $lines[$i]->product_type == 9)
|
||||
{
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$cmd->classifyBilled($user);
|
||||
$cmd->classifyBilled($user); // TODO Move this in workflow like done for customer orders
|
||||
|
||||
if(!empty($createbills_onebythird) && empty($TFactThird[$cmd->socid])) $TFactThird[$cmd->socid] = $object;
|
||||
else $TFact[$object->id] = $object;
|
||||
@ -410,27 +407,30 @@ if (empty($reshook))
|
||||
$TAllFact = empty($createbills_onebythird) ? $TFact : $TFactThird;
|
||||
$toselect = array();
|
||||
|
||||
if(!empty($validate_invoices)) {
|
||||
if (! $error && $validate_invoices) {
|
||||
|
||||
$massaction = $action = 'builddoc';
|
||||
|
||||
foreach($TAllFact as &$object) {
|
||||
foreach($TAllFact as &$object)
|
||||
{
|
||||
$object->validate($user);
|
||||
$toselect[] = $object->id; // For builddoc action
|
||||
if ($result <= 0)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages($object->error, $object->errors, 'errors');
|
||||
break;
|
||||
}
|
||||
|
||||
$id = $object->id; // For builddoc action
|
||||
|
||||
// Fac builddoc
|
||||
$donotredirect = 1;
|
||||
$upload_dir = $conf->facture->dir_output;
|
||||
$permissioncreate=$user->rights->facture->creer;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';
|
||||
}
|
||||
|
||||
$objectclass='Facture';
|
||||
$objectlabel='Invoice';
|
||||
$permtoread = $user->rights->facture->lire;
|
||||
$permtodelete = $user->rights->facture->supprimer;
|
||||
$uploaddir = $conf->facture->dir_output;
|
||||
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
|
||||
|
||||
$massaction = $action = 'confirm_createbills';
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
|
||||
@ -781,12 +781,13 @@ class Holiday extends CommonObject
|
||||
$num_rows = $this->db->num_rows($resql); // Note, we can have 2 records if on is morning and the other one is afternoon
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
$arrayofrecord=array();
|
||||
$i=0;
|
||||
while ($i < $num_rows)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
// Note: $obj->halday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning
|
||||
// Note: $obj->halfday is 0:Full days, 2:Sart afternoon end morning, -1:Start afternoon, 1:End morning
|
||||
$arrayofrecord[$obj->rowid]=array('date_start'=>$this->db->jdate($obj->date_start), 'date_end'=>$this->db->jdate($obj->date_end), 'halfday'=>$obj->halfday);
|
||||
$i++;
|
||||
}
|
||||
|
||||
@ -418,7 +418,7 @@ foreach($typeleaves as $key => $val)
|
||||
//$labeltoshow .= ($val['delay'] > 0 ? ' ('.$langs->trans("NoticePeriod").': '.$val['delay'].' '.$langs->trans("days").')':'');
|
||||
$arraytypeleaves[$val['rowid']]=$labeltoshow;
|
||||
}
|
||||
print $form->selectarray('search_type', $arraytypeleaves, (GETPOST('search_type')?GETPOST('search_type'):''), 1);
|
||||
print $form->selectarray('search_type', $arraytypeleaves, $search_type, 1);
|
||||
print '</td>';
|
||||
|
||||
// Duration
|
||||
|
||||
@ -253,7 +253,7 @@ CREATE TABLE llx_expensereport_rules (
|
||||
code_expense_rules_type varchar(50) NOT NULL,
|
||||
is_for_all tinyint DEFAULT '0',
|
||||
entity integer DEFAULT 1
|
||||
);
|
||||
)ENGINE=innodb;
|
||||
|
||||
ALTER TABLE llx_expensereport_det ADD COLUMN rule_warning_message text;
|
||||
ALTER TABLE llx_expensereport_det ADD COLUMN fk_c_exp_tax_cat integer;
|
||||
@ -302,14 +302,16 @@ insert into llx_c_action_trigger (code,label,description,elementtype,rang) value
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_CLOSE_SIGNED','Price request closed signed','Executed when a customer proposal is closed signed','proposal_supplier',10);
|
||||
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('PROPOSAL_SUPPLIER_CLOSE_REFUSED','Price request closed refused','Executed when a customer proposal is closed refused','proposal_supplier',10);
|
||||
|
||||
DROP TABLE llx_projet_task_comment;
|
||||
|
||||
CREATE TABLE llx_projet_task_comment (
|
||||
CREATE TABLE llx_comment (
|
||||
rowid integer AUTO_INCREMENT PRIMARY KEY,
|
||||
datec datetime DEFAULT NULL,
|
||||
tms timestamp,
|
||||
description text NOT NULL,
|
||||
fk_user integer DEFAULT NULL,
|
||||
fk_task integer DEFAULT NULL,
|
||||
fk_user_author integer DEFAULT NULL,
|
||||
fk_element integer DEFAULT NULL,
|
||||
element_type varchar(50) DEFAULT NULL,
|
||||
entity integer DEFAULT 1,
|
||||
import_key varchar(125) DEFAULT NULL
|
||||
)ENGINE=innodb;
|
||||
|
||||
@ -148,7 +148,8 @@ Doctype=Type of document
|
||||
Docdate=Date
|
||||
Docref=Reference
|
||||
Code_tiers=Thirdparty
|
||||
Labelcompte=Label account
|
||||
LabelAccount=Label account
|
||||
LabelOperation=Label operation
|
||||
Sens=Sens
|
||||
Codejournal=Journal
|
||||
NumPiece=Piece number
|
||||
|
||||
@ -584,7 +584,7 @@ Module3100Desc=Add a Skype button into users / third parties / contacts / member
|
||||
Module3200Name=Non Reversible Logs
|
||||
Module3200Desc=Activate log of some business events into a non reversible log. Events are archived in real-time. The log is a table of chained event that can be then read and exported. This module may be mandatory for some countries.
|
||||
Module4000Name=HRM
|
||||
Module4000Desc=Human resources management (mangement of department, employee contracts and feelings)
|
||||
Module4000Desc=Human resources management (management of department, employee contracts and feelings)
|
||||
Module5000Name=Multi-company
|
||||
Module5000Desc=Allows you to manage multiple companies
|
||||
Module6000Name=Workflow
|
||||
|
||||
@ -12,6 +12,7 @@ Event=Event
|
||||
Events=Events
|
||||
EventsNb=Number of events
|
||||
ListOfActions=List of events
|
||||
EventReports=Event reports
|
||||
Location=Location
|
||||
ToUserOfGroup=To any user in group
|
||||
EventOnFullDay=Event on all day(s)
|
||||
|
||||
@ -597,6 +597,7 @@ Undo=Undo
|
||||
Redo=Redo
|
||||
ExpandAll=Expand all
|
||||
UndoExpandAll=Undo expand
|
||||
SeeAll=See all
|
||||
Reason=Reason
|
||||
FeatureNotYetSupported=Feature not yet supported
|
||||
CloseWindow=Close window
|
||||
@ -873,3 +874,8 @@ SearchIntoContracts=Contracts
|
||||
SearchIntoCustomerShipments=Customer shipments
|
||||
SearchIntoExpenseReports=Expense reports
|
||||
SearchIntoLeaves=Leaves
|
||||
CommentLink=Comments
|
||||
NbComments=Number of comments
|
||||
CommentPage=Comments space
|
||||
CommentAdded=Comment added
|
||||
CommentDeleted=Comment deleted
|
||||
|
||||
@ -12,7 +12,7 @@ ObjectKey=Object key
|
||||
ModuleInitialized=Module initialized
|
||||
FilesForObjectInitialized=Files for new object '%s' initialized
|
||||
FilesForObjectUpdated=Files for object '%s' updated (.sql files and .class.php file)
|
||||
ModuleBuilderDescdescription=Enter here all general information that describe your module
|
||||
ModuleBuilderDescdescription=Enter here all general information that describe your module.
|
||||
ModuleBuilderDescspecifications=You can enter here a long text to describe the specifications of your module that is not already structured into other tabs. So you have within easy reach all the rules to develop. Also this text content will be included into the generated documentation (see last tab). You can use Markdown format, but it is recommanded to use Asciidoc format (Comparison between .md and .asciidoc: http://asciidoctor.org/docs/user-manual/#compared-to-markdown)
|
||||
ModuleBuilderDescobjects=Define here the objects you want to manage with your module. A CRUD DAO class, SQL files, page to list record of objects, to create/edit/view a record and an API will be generated.
|
||||
ModuleBuilderDescmenus=This tab is dedicated to define menu entries provided by your module.
|
||||
@ -77,7 +77,7 @@ SpecDefDesc=Enter here all documentation you want to provide with your module th
|
||||
LanguageDefDesc=Enter in this files, all the key and the translation for each language file.
|
||||
MenusDefDesc=Define here the menus provided by your module (once defined, they are visible into the menu editor %s)
|
||||
PermissionsDefDesc=Define here the new permissions provided by your module (once defined, they are visible into the default permissions setup %s)
|
||||
HooksDefDesc=Define in the <b>module_parts['hooks']</b> property in the module descriptor the context of hooks you want to manage (list of contexts can be found by a search on '<b>initHooks(</b>' in core code).<br>Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on '<b>executeHooks</b>' in core code).
|
||||
TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed
|
||||
HooksDefDesc=Define in the <b>module_parts['hooks']</b> property, in the module descriptor, the context of hooks you want to manage (list of contexts can be found by a search on '<b>initHooks(</b>' in core code).<br>Edit the hook file to add code of your hooked functions (hookable functions can be found by a search on '<b>executeHooks</b>' in core code).
|
||||
TriggerDefDesc=Define in the trigger file the code you want to execute for each business event executed.
|
||||
SeeIDsInUse=See IDs in use in your installation
|
||||
SeeReservedIDsRangeHere=See range of reserved IDs
|
||||
@ -210,8 +210,4 @@ OppStatusLOST=Lost
|
||||
Budget=Budget
|
||||
# Comments trans
|
||||
AllowCommentOnTask=Allow user comments on tasks
|
||||
TaskCommentLinks=Comments
|
||||
TaskNbComments=Number of comments
|
||||
TaskComment=Task's comments space
|
||||
CommentAdded=Comment added
|
||||
CommentDeleted=Comment deleted
|
||||
AllowCommentOnProject=Allow user comments on projects
|
||||
|
||||
@ -842,3 +842,8 @@ SearchIntoContracts=Contrats
|
||||
SearchIntoCustomerShipments=Expéditions clients
|
||||
SearchIntoExpenseReports=Notes de frais
|
||||
SearchIntoLeaves=Congés
|
||||
CommentLink=Commentaires
|
||||
NbComments=Nombre de commentaires
|
||||
CommentPage=Espace commentaires
|
||||
CommentAdded=Commentaire ajouté avec succès
|
||||
CommentDeleted=Commentaire supprimé avec succès
|
||||
|
||||
@ -209,8 +209,4 @@ OppStatusLOST=Perdu
|
||||
Budget=Budget
|
||||
#Comments trans
|
||||
AllowCommentOnTask=Autoriser les commentaires entre utilisateurs sur les tâches
|
||||
TaskCommentLinks=Commentaires
|
||||
TaskNbComments=Nombre de commentaires
|
||||
TaskComment=Tâches espace commentaires
|
||||
CommentAdded=Commentaire ajouté avec succès
|
||||
CommentDeleted=Commentaire supprimé avec succès
|
||||
AllowCommentOnProject=Autoriser les commentaires entre utilisateurs sur les projets
|
||||
|
||||
@ -28,6 +28,7 @@ if (! defined('NOSCANPOSTFORINJECTION')) define('NOSCANPOSTFORINJECTION','1');
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/modulebuilder.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
@ -764,6 +765,7 @@ if ($action == 'reset' && $user->admin)
|
||||
*/
|
||||
|
||||
$form = new Form($db);
|
||||
$formadmin = new FormAdmin($db);
|
||||
|
||||
// Set dir where external modules are installed
|
||||
if (! dol_is_dir($dirins))
|
||||
@ -1252,6 +1254,20 @@ elseif (! empty($module))
|
||||
print $langs->trans("LanguageDefDesc").'<br>';
|
||||
print '<br>';
|
||||
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addlanguage">';
|
||||
print '<input type="hidden" name="file" value="'.dol_escape_htmltag($file).'">';
|
||||
print '<input type="hidden" name="tab" value="'.$tab.'">';
|
||||
print '<input type="hidden" name="module" value="'.$module.'">';
|
||||
print $formadmin->select_language($conf->global->MAIN_LANG_DEFAULT, 'MAIN_LANG_DEFAULT', 1, 0, 0, 0, 0, 'minwidth300', 1);
|
||||
print '<input type="submit" name="addlanguage" class="button" value="'.dol_escape_htmltag($langs->trans("AddLanguageFile")).'"><br>';
|
||||
print '</form>';
|
||||
|
||||
print '<br>';
|
||||
print '<br>';
|
||||
|
||||
$langfiles=dol_dir_list(dol_buildpath($modulelowercase.'/langs', 0), 'files', 1, '\.lang$');
|
||||
|
||||
foreach ($langfiles as $langfile)
|
||||
|
||||
@ -16,24 +16,24 @@
|
||||
*/
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/product/class/product.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
/**
|
||||
* API class for products
|
||||
*
|
||||
* @access protected
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*/
|
||||
class Products extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'ref',
|
||||
'label'
|
||||
'label'
|
||||
);
|
||||
|
||||
/**
|
||||
@ -53,30 +53,30 @@ class Products extends DolibarrApi
|
||||
|
||||
/**
|
||||
* Get properties of a product object
|
||||
*
|
||||
*
|
||||
* Return an array with product informations
|
||||
*
|
||||
* @param int $id ID of product
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
* TODO implement getting a product by ref or by $ref_ext
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->produit->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->product->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Product not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('product',$this->product->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
|
||||
$this->product->load_stock();
|
||||
|
||||
return $this->_cleanObjectDatas($this->product);
|
||||
@ -84,9 +84,9 @@ class Products extends DolibarrApi
|
||||
|
||||
/**
|
||||
* List products
|
||||
*
|
||||
*
|
||||
* Get a list of products
|
||||
*
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
@ -98,9 +98,9 @@ class Products extends DolibarrApi
|
||||
*/
|
||||
function index($sortfield = "t.ref", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $category=0, $sqlfilters = '') {
|
||||
global $db, $conf;
|
||||
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
|
||||
$socid = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
|
||||
|
||||
$sql = "SELECT t.rowid, t.ref, t.ref_ext";
|
||||
@ -121,7 +121,7 @@ class Products extends DolibarrApi
|
||||
// Show services
|
||||
if ($mode == 2) $sql.= " AND t.fk_product_type = 1";
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
@ -130,7 +130,7 @@ class Products extends DolibarrApi
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
@ -165,10 +165,10 @@ class Products extends DolibarrApi
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create product object
|
||||
*
|
||||
*
|
||||
* @param array $request_data Request data
|
||||
* @return int ID of product
|
||||
*/
|
||||
@ -179,35 +179,35 @@ class Products extends DolibarrApi
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->product->$field = $value;
|
||||
}
|
||||
if ($this->product->create(DolibarrApiAccess::$user) < 0) {
|
||||
throw new RestException(500, "Error creating product", array_merge(array($this->product->error), $this->product->errors));
|
||||
}
|
||||
|
||||
|
||||
return $this->product->id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update product
|
||||
*
|
||||
*
|
||||
* @param int $id Id of product to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
function put($id, $request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->produit->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->product->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Product not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('product',$this->product->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -216,16 +216,16 @@ class Products extends DolibarrApi
|
||||
if ($field == 'id') continue;
|
||||
$this->product->$field = $value;
|
||||
}
|
||||
|
||||
|
||||
if($this->product->update($id, DolibarrApiAccess::$user,1,'update'))
|
||||
return $this->get ($id);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete product
|
||||
*
|
||||
*
|
||||
* @param int $id Product ID
|
||||
* @return array
|
||||
*/
|
||||
@ -238,18 +238,18 @@ class Products extends DolibarrApi
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Product not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('product',$this->product->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
|
||||
// The Product::delete() method uses the global variable $user.
|
||||
global $user;
|
||||
$user = DolibarrApiAccess::$user;
|
||||
|
||||
return $this->product->delete(DolibarrApiAccess::$user);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get categories for a product
|
||||
*
|
||||
@ -263,9 +263,25 @@ class Products extends DolibarrApi
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
|
||||
$categories = new Categories();
|
||||
return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'product', $id);
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$categories = new Categorie($this->db);
|
||||
|
||||
$result = $categories->getListForItem($id, 'product', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -275,17 +291,17 @@ class Products extends DolibarrApi
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object) {
|
||||
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
|
||||
unset($object->regeximgext);
|
||||
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
*
|
||||
* @param array $data Datas to validate
|
||||
* @return array
|
||||
* @throws RestException
|
||||
|
||||
@ -115,7 +115,7 @@ if ($action == 'order' && isset($_POST['valid']))
|
||||
$suppliers = array();
|
||||
for ($i = 0; $i < $linecount; $i++)
|
||||
{
|
||||
if (GETPOST($i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0)
|
||||
if (GETPOST('choose' . $i, 'alpha') === 'on' && GETPOST('fourn' . $i, 'int') > 0)
|
||||
{
|
||||
//one line
|
||||
$box = $i;
|
||||
@ -616,7 +616,7 @@ while ($i < ($limit ? min($num, $limit) : $num))
|
||||
|
||||
// Select field
|
||||
//print '<td><input type="checkbox" class="check" name="' . $i . '"' . $disabled . '></td>';
|
||||
print '<td><input type="checkbox" class="check" name="'.$i.'"></td>';
|
||||
print '<td><input type="checkbox" class="check" name="choose'.$i.'"></td>';
|
||||
|
||||
print '<td class="nowrap">'.$prod->getNomUrl(1, '').'</td>';
|
||||
|
||||
|
||||
@ -918,6 +918,17 @@ print '</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
/* Kept as hidden feature because this will be "probaly be supported by standard event feature in a future
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("AllowCommentOnProject").'</td>';
|
||||
|
||||
print '<td align="center" width="300">';
|
||||
echo ajax_constantonoff('PROJECT_ALLOW_COMMENT_ON_PROJECT');
|
||||
print '</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td>'.$langs->trans("AllowCommentOnTask").'</td>';
|
||||
|
||||
@ -926,6 +937,7 @@ echo ajax_constantonoff('PROJECT_ALLOW_COMMENT_ON_TASK');
|
||||
print '</td>';
|
||||
print '<td align="center" width="20"> </td>';
|
||||
print '</tr>';
|
||||
*/
|
||||
|
||||
print '</table></form>';
|
||||
|
||||
|
||||
@ -1192,16 +1192,20 @@ elseif ($object->id > 0)
|
||||
$genallowed=($user->rights->projet->lire && $userAccess > 0);
|
||||
$delallowed=($user->rights->projet->creer && $userWrite > 0);
|
||||
|
||||
$var=true;
|
||||
|
||||
print $formfile->showdocuments('project',$filename,$filedir,$urlsource,$genallowed,$delallowed,$object->modelpdf);
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
$MAX = 10;
|
||||
|
||||
$morehtmlright = '<a href="'.DOL_URL_ROOT.'/projet/info.php?id='.$object->id.'">';
|
||||
$morehtmlright.= $langs->trans("SeeAll");
|
||||
$morehtmlright.= '</a>';
|
||||
|
||||
// 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', $socid, 1, '', 10);
|
||||
$somethingshown = $formactions->showactions($object, 'project', $socid, 1, '', $MAX, '', $morehtmlright);
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
||||
@ -296,6 +296,7 @@ class Project extends CommonObject
|
||||
$sql.= ", fk_user_close=" . ($this->fk_user_close > 0 ? $this->fk_user_close : "null");
|
||||
$sql.= ", opp_amount = " . (strcmp($this->opp_amount, '') ? price2num($this->opp_amount) : "null");
|
||||
$sql.= ", budget_amount = " . (strcmp($this->budget_amount, '') ? price2num($this->budget_amount) : "null");
|
||||
$sql.= ", fk_user_modif = " . $user->id;
|
||||
$sql.= " WHERE rowid = " . $this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
@ -390,7 +391,7 @@ class Project extends CommonObject
|
||||
if (empty($id) && empty($ref)) return -1;
|
||||
|
||||
$sql = "SELECT rowid, ref, title, description, public, datec, opp_amount, budget_amount,";
|
||||
$sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf";
|
||||
$sql.= " tms, dateo, datee, date_close, fk_soc, fk_user_creat, fk_user_modif, fk_user_close, fk_statut, fk_opp_status, opp_percent, note_private, note_public, model_pdf";
|
||||
$sql.= " FROM " . MAIN_DB_PREFIX . "projet";
|
||||
if (! empty($id))
|
||||
{
|
||||
@ -428,6 +429,7 @@ class Project extends CommonObject
|
||||
$this->note_public = $obj->note_public;
|
||||
$this->socid = $obj->fk_soc;
|
||||
$this->user_author_id = $obj->fk_user_creat;
|
||||
$this->user_modification_id = $obj->fk_user_modif;
|
||||
$this->user_close_id = $obj->fk_user_close;
|
||||
$this->public = $obj->public;
|
||||
$this->statut = $obj->fk_statut;
|
||||
@ -441,6 +443,7 @@ class Project extends CommonObject
|
||||
|
||||
// Retreive all extrafield for thirdparty
|
||||
$this->fetch_optionals();
|
||||
$this->fetchComments();
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -1832,332 +1832,4 @@ class Task extends CommonObject
|
||||
|
||||
return ($datetouse > 0 && ($datetouse < ($now - $conf->projet->task->warning_delay)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return nb comments already posted
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function getNbComments()
|
||||
{
|
||||
return count($this->comments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load comments linked with current task
|
||||
*
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
public function fetchComments()
|
||||
{
|
||||
$this->comments = array();
|
||||
$sql = "SELECT";
|
||||
$sql.= " c.rowid";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c";
|
||||
$sql.= " WHERE c.fk_task = ".$this->id;
|
||||
$sql.= " ORDER BY c.tms DESC";
|
||||
|
||||
dol_syslog(get_class($this)."::fetchComments", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_rows = $this->db->num_rows($resql);
|
||||
if ($num_rows > 0)
|
||||
{
|
||||
while($obj = $this->db->fetch_object($resql))
|
||||
{
|
||||
$comment = new TaskComment($this->db);
|
||||
$comment->fetch($obj->rowid);
|
||||
$this->comments[] = $comment;
|
||||
}
|
||||
return $num_rows;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class to manage tasks
|
||||
*/
|
||||
class TaskComment extends CommonObject
|
||||
{
|
||||
public $element='project_task_comment'; //!< Id that identify managed objects
|
||||
public $table_element='projet_task_comment'; //!< Name of table without prefix where object is stored
|
||||
public $fk_element='fk_task';
|
||||
public $picto = 'task';
|
||||
|
||||
var $fk_task;
|
||||
|
||||
var $description;
|
||||
|
||||
var $tms;
|
||||
|
||||
var $datec;
|
||||
|
||||
var $fk_user;
|
||||
|
||||
var $entity;
|
||||
|
||||
var $import_key;
|
||||
|
||||
public $oldcopy;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create into database
|
||||
*
|
||||
* @param User $user User that create
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, Id of created object if OK
|
||||
*/
|
||||
function create($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
|
||||
$error=0;
|
||||
|
||||
// Insert request
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."projet_task_comment (";
|
||||
$sql.= "description";
|
||||
$sql.= ", datec";
|
||||
$sql.= ", fk_task";
|
||||
$sql.= ", fk_user";
|
||||
$sql.= ", entity";
|
||||
$sql.= ", import_key";
|
||||
$sql.= ") VALUES (";
|
||||
$sql.= "'".$this->db->escape($this->description)."'";
|
||||
$sql.= ", ".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null');
|
||||
$sql.= ", '".(isset($this->fk_task)?$this->fk_task:"null")."'";
|
||||
$sql.= ", '".(isset($this->fk_user)?$this->fk_user:"null")."'";
|
||||
$sql.= ", ".(!empty($this->entity)?$this->entity:'1');
|
||||
$sql.= ", ".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
|
||||
$sql.= ")";
|
||||
|
||||
//var_dump($this->db);
|
||||
//echo $sql;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::create", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."projet_task_comment");
|
||||
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TASK_COMMENT_CREATE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return $this->id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load object in memory from database
|
||||
*
|
||||
* @param int $id Id object
|
||||
* @param int $ref ref object
|
||||
* @return int <0 if KO, 0 if not found, >0 if OK
|
||||
*/
|
||||
function fetch($id, $ref='')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
$sql = "SELECT";
|
||||
$sql.= " c.rowid,";
|
||||
$sql.= " c.description,";
|
||||
$sql.= " c.datec,";
|
||||
$sql.= " c.tms,";
|
||||
$sql.= " c.fk_task,";
|
||||
$sql.= " c.fk_user,";
|
||||
$sql.= " c.entity,";
|
||||
$sql.= " c.import_key";
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."projet_task_comment as c";
|
||||
$sql.= " WHERE c.rowid = ".$id;
|
||||
|
||||
dol_syslog(get_class($this)."::fetch", LOG_DEBUG);
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num_rows = $this->db->num_rows($resql);
|
||||
|
||||
if ($num_rows)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
|
||||
$this->id = $obj->rowid;
|
||||
$this->description = $obj->description;
|
||||
$this->datec = $this->db->jdate($obj->datec);
|
||||
$this->tms = $obj->tms;
|
||||
$this->fk_user = $obj->fk_user;
|
||||
$this->fk_task = $obj->fk_task;
|
||||
$this->entity = $obj->entity;
|
||||
$this->import_key = $obj->import_key;
|
||||
}
|
||||
|
||||
$this->db->free($resql);
|
||||
|
||||
if ($num_rows) return 1;
|
||||
else return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error="Error ".$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Update database
|
||||
*
|
||||
* @param User $user User that modify
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <=0 if KO, >0 if OK
|
||||
*/
|
||||
function update(User $user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
$error=0;
|
||||
|
||||
// Clean parameters
|
||||
if (isset($this->fk_task)) $this->fk_project=(int) trim($this->fk_task);
|
||||
if (isset($this->fk_user)) $this->fk_user=(int) trim($this->fk_user);
|
||||
if (isset($this->description)) $this->description=trim($this->description);
|
||||
|
||||
|
||||
// Update request
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."projet_task_comment SET";
|
||||
$sql.= " description=".(isset($this->description)?"'".$this->db->escape($this->description)."'":"null").",";
|
||||
$sql.= " datec=".($this->datec!=''?"'".$this->db->idate($this->datec)."'":'null').",";
|
||||
$sql.= " fk_task=".(isset($this->fk_task)?$this->fk_task:"null").",";
|
||||
$sql.= " fk_user=".(isset($this->fk_user)?$this->fk_user:"null").",";
|
||||
$sql.= " entity=".(!empty($this->entity)?$this->entity:'1').",";
|
||||
$sql.= " import_key=".(!empty($this->import_key)?"'".$this->db->escape($this->import_key)."'":"null");
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
dol_syslog(get_class($this)."::update", LOG_DEBUG);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TASK_COMMENT_MODIFY',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete task from database
|
||||
*
|
||||
* @param User $user User that delete
|
||||
* @param int $notrigger 0=launch triggers after, 1=disable triggers
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function delete($user, $notrigger=0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
require_once DOL_DOCUMENT_ROOT . '/core/lib/files.lib.php';
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
|
||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."projet_task_comment";
|
||||
$sql.= " WHERE rowid=".$this->id;
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
if (! $notrigger)
|
||||
{
|
||||
// Call trigger
|
||||
$result=$this->call_trigger('TASK_COMMENT_DELETE',$user);
|
||||
if ($result < 0) { $error++; }
|
||||
// End call triggers
|
||||
}
|
||||
}
|
||||
|
||||
// Commit or rollback
|
||||
if ($error)
|
||||
{
|
||||
foreach($this->errors as $errmsg)
|
||||
{
|
||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||
}
|
||||
$this->db->rollback();
|
||||
return -1*$error;
|
||||
}else{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
189
htdocs/projet/comment.php
Normal file
189
htdocs/projet/comment.php
Normal file
@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/* Copyright (C) 2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
|
||||
* Copyright (C) 2006-2017 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2010-2012 Regis Houssin <regis.houssin@capnetworks.com>
|
||||
*
|
||||
* 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
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file htdocs/projet/tasks/task.php
|
||||
* \ingroup project
|
||||
* \brief Page of a project task
|
||||
*/
|
||||
|
||||
require '../main.inc.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/project.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formprojet.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/modules_project.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/extrafields.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load("companies");
|
||||
|
||||
$id=GETPOST('id','int');
|
||||
$idcomment=GETPOST('idcomment','int');
|
||||
$ref=GETPOST("ref",'alpha',1); // task ref
|
||||
$objectref=GETPOST("taskref",'alpha'); // task ref
|
||||
$action=GETPOST('action','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$withproject=GETPOST('withproject','int');
|
||||
$project_ref=GETPOST('project_ref','alpha');
|
||||
$planned_workload=((GETPOST('planned_workloadhour','int')!='' || GETPOST('planned_workloadmin','int')!='') ? (GETPOST('planned_workloadhour','int')>0?GETPOST('planned_workloadhour','int')*3600:0) + (GETPOST('planned_workloadmin','int')>0?GETPOST('planned_workloadmin','int')*60:0) : '');
|
||||
|
||||
// Security check
|
||||
$socid=0;
|
||||
//if ($user->societe_id > 0) $socid = $user->societe_id; // For external user, no check is done on company because readability is managed by public status of project and assignement.
|
||||
if (! $user->rights->projet->lire) accessforbidden();
|
||||
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('projectcard','globalcard'));
|
||||
|
||||
$object = new Project($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$object = new Project($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
// Load object
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$ret = $object->fetch($id,$ref); // If we create project, ref may be defined into POST but record does not yet exists into database
|
||||
if ($ret > 0) {
|
||||
$object->fetch_thirdparty();
|
||||
$id=$object->id;
|
||||
}
|
||||
}
|
||||
|
||||
// include comment actions
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_comments.inc.php';
|
||||
|
||||
/*
|
||||
* View
|
||||
*/
|
||||
|
||||
|
||||
llxHeader('', $langs->trans("CommentPage"));
|
||||
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
$formfile = new FormFile($db);
|
||||
|
||||
// Tabs for project
|
||||
$tab = 'project_comment';
|
||||
$head = project_prepare_head($object);
|
||||
dol_fiche_head($head, $tab, $langs->trans("Project"), - 1, ($object->public ? 'projectpub' : 'project'));
|
||||
|
||||
$param = ($mode == 'mine' ? '&mode=mine' : '');
|
||||
|
||||
// Project card
|
||||
|
||||
$linkback = '<a href="' . DOL_URL_ROOT . '/projet/list.php?restore_lastsearch_values=1">' . $langs->trans("BackToList") . '</a>';
|
||||
|
||||
$morehtmlref = '<div class="refidno">';
|
||||
// Title
|
||||
$morehtmlref .= $object->title;
|
||||
// Thirdparty
|
||||
if ($object->thirdparty->id > 0) {
|
||||
$morehtmlref .= '<br>' . $langs->trans('ThirdParty') . ' : ' . $object->thirdparty->getNomUrl(1, 'project');
|
||||
}
|
||||
$morehtmlref .= '</div>';
|
||||
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire) {
|
||||
$objectsListId = $object->getProjectsAuthorizedForUser($user, 0, 0);
|
||||
$object->next_prev_filter = " rowid in (" . (count($objectsListId) ? join(',', array_keys($objectsListId)) : '0') . ")";
|
||||
}
|
||||
|
||||
dol_banner_tab($object, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
print '<div class="fichehalfleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Visibility
|
||||
print '<tr><td class="titlefield">' . $langs->trans("Visibility") . '</td><td>';
|
||||
if ($object->public) print $langs->trans('SharedProject');
|
||||
else
|
||||
print $langs->trans('PrivateProject');
|
||||
print '</td></tr>';
|
||||
|
||||
// Date start - end
|
||||
print '<tr><td>' . $langs->trans("DateStart") . ' - ' . $langs->trans("DateEnd") . '</td><td>';
|
||||
print dol_print_date($object->date_start, 'day');
|
||||
$end = dol_print_date($object->date_end, 'day');
|
||||
if ($end) print ' - ' . $end;
|
||||
print '</td></tr>';
|
||||
|
||||
// Budget
|
||||
print '<tr><td>' . $langs->trans("Budget") . '</td><td>';
|
||||
if (strcmp($object->budget_amount, '')) print price($object->budget_amount, '', $langs, 1, 0, 0, $conf->currency);
|
||||
print '</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
$cols = 2;
|
||||
// include DOL_DOCUMENT_ROOT . '/core/tpl/extrafields_view.tpl.php';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
print '<div class="fichehalfright">';
|
||||
print '<div class="ficheaddleft">';
|
||||
print '<div class="underbanner clearboth"></div>';
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Description
|
||||
print '<td class="titlefield tdtop">' . $langs->trans("Description") . '</td><td>';
|
||||
print nl2br($object->description);
|
||||
print '</td></tr>';
|
||||
|
||||
// Categories
|
||||
if ($conf->categorie->enabled) {
|
||||
print '<tr><td valign="middle">' . $langs->trans("Categories") . '</td><td>';
|
||||
print $form->showCategories($object->id, 'project', 1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
// Nb comments
|
||||
print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
|
||||
print $object->getNbComments();
|
||||
print '</td></tr>';
|
||||
|
||||
print '</table>';
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
print '<br>';
|
||||
|
||||
// Include comment tpl view
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_comment.tpl.php';
|
||||
|
||||
|
||||
llxFooter();
|
||||
$db->close();
|
||||
@ -156,42 +156,32 @@ if ($permok)
|
||||
}
|
||||
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
|
||||
//print '<div class="tabsAction">';
|
||||
$morehtmlcenter='';
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddAction").'</a>';
|
||||
$morehtmlcenter.='<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'&backtopage='.urlencode($_SERVER["PHP_SELF"].'?id='.$object->id).'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
$morehtmlcenter.='<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
//print '</div>';
|
||||
|
||||
if (!empty($object->id))
|
||||
{
|
||||
$param='&id='.$object->id;
|
||||
print '<br>';
|
||||
|
||||
$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
|
||||
/*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);
|
||||
|
||||
print_barre_liste($langs->trans("ActionsOnProject"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
|
||||
|
||||
// List of all actions
|
||||
$filters=array();
|
||||
$filters['search_agenda_label']=$search_agenda_label;
|
||||
|
||||
@ -366,7 +366,7 @@ if ($action == 'create' && $user->rights->projet->creer && (empty($object->third
|
||||
print '</td></tr>';
|
||||
|
||||
print '<tr><td class="fieldrequired">'.$langs->trans("Label").'</td><td>';
|
||||
print '<input type="text" name="label" class="flat minwidth300" value="'.$label.'">';
|
||||
print '<input type="text" name="label" autofocus class="flat minwidth300" value="'.$label.'">';
|
||||
print '</td></tr>';
|
||||
|
||||
// List of projects
|
||||
|
||||
@ -33,7 +33,6 @@ require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formfile.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/modules/project/task/modules_task.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
|
||||
|
||||
$langs->load("projects");
|
||||
$langs->load("companies");
|
||||
@ -41,7 +40,7 @@ $langs->load("companies");
|
||||
$id=GETPOST('id','int');
|
||||
$idcomment=GETPOST('idcomment','int');
|
||||
$ref=GETPOST("ref",'alpha',1); // task ref
|
||||
$taskref=GETPOST("taskref",'alpha'); // task ref
|
||||
$objectref=GETPOST("taskref",'alpha'); // task ref
|
||||
$action=GETPOST('action','alpha');
|
||||
$confirm=GETPOST('confirm','alpha');
|
||||
$withproject=GETPOST('withproject','int');
|
||||
@ -56,69 +55,25 @@ if (! $user->rights->projet->lire) accessforbidden();
|
||||
// Initialize technical object to manage hooks of page. Note that conf->hooks_modules contains array of hook context
|
||||
$hookmanager->initHooks(array('projecttaskcard','globalcard'));
|
||||
|
||||
$task = new Task($db);
|
||||
$object = new TaskComment($db);
|
||||
$object = new Task($db);
|
||||
$extrafields = new ExtraFields($db);
|
||||
$projectstatic = new Project($db);
|
||||
$userstatic = new User($db);
|
||||
|
||||
// fetch optionals attributes and labels
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($task->table_element);
|
||||
$extralabels=$extrafields->fetch_name_optionals_label($object->table_element);
|
||||
|
||||
|
||||
/*
|
||||
* Actions
|
||||
*/
|
||||
|
||||
if ($action == 'addcomment')
|
||||
{
|
||||
if (!empty($_POST['comment_description']))
|
||||
{
|
||||
$object->description = GETPOST('comment_description');
|
||||
$object->datec = time();
|
||||
$object->fk_task = $id;
|
||||
$object->fk_user = $user->id;
|
||||
$object->entity = $conf->entity;
|
||||
if ($object->create($user) > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("CommentAdded"), null, 'mesgs');
|
||||
header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':''));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($task->error,$task->errors,'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($action == 'deletecomment')
|
||||
{
|
||||
if ($object->fetch($idcomment) >= 0)
|
||||
{
|
||||
if ($object->delete($user) > 0)
|
||||
{
|
||||
setEventMessages($langs->trans("CommentDeleted"), null, 'mesgs');
|
||||
header('Location: '.DOL_URL_ROOT.'/projet/tasks/comment.php?id='.$id.($withproject?'&withproject=1':''));
|
||||
exit;
|
||||
}
|
||||
else
|
||||
{
|
||||
setEventMessages($task->error,$task->errors,'errors');
|
||||
$action='';
|
||||
}
|
||||
}
|
||||
}
|
||||
// include comment actions
|
||||
include DOL_DOCUMENT_ROOT . '/core/actions_comments.inc.php';
|
||||
|
||||
// Retreive First Task ID of Project if withprojet is on to allow project prev next to work
|
||||
if (! empty($project_ref) && ! empty($withproject))
|
||||
{
|
||||
if ($projectstatic->fetch('',$project_ref) > 0)
|
||||
{
|
||||
$tasksarray=$task->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
|
||||
if (count($tasksarray) > 0)
|
||||
$objectsarray=$object->getTasksArray(0, 0, $projectstatic->id, $socid, 0);
|
||||
if (count($objectsarray) > 0)
|
||||
{
|
||||
$id=$tasksarray[0]->id;
|
||||
$id=$objectsarray[0]->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -132,7 +87,7 @@ if (! empty($project_ref) && ! empty($withproject))
|
||||
*/
|
||||
|
||||
|
||||
llxHeader('', $langs->trans("TaskComment"));
|
||||
llxHeader('', $langs->trans("CommentPage"));
|
||||
|
||||
$form = new Form($db);
|
||||
$formother = new FormOther($db);
|
||||
@ -140,14 +95,14 @@ $formfile = new FormFile($db);
|
||||
|
||||
if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
if ($task->fetch($id,$ref) > 0)
|
||||
if ($object->fetch($id,$ref) > 0)
|
||||
{
|
||||
$res=$task->fetch_optionals($task->id,$extralabels);
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
$result=$projectstatic->fetch($task->fk_project);
|
||||
$result=$projectstatic->fetch($object->fk_project);
|
||||
if (! empty($projectstatic->socid)) $projectstatic->fetch_thirdparty();
|
||||
|
||||
$task->project = clone $projectstatic;
|
||||
$object->project = clone $projectstatic;
|
||||
|
||||
$userWrite = $projectstatic->restrictedProjectArea($user,'write');
|
||||
|
||||
@ -177,8 +132,8 @@ if ($id > 0 || ! empty($ref))
|
||||
// Define a complementary filter for search of next/prev ref.
|
||||
if (! $user->rights->projet->all->lire)
|
||||
{
|
||||
$tasksListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
|
||||
$projectstatic->next_prev_filter=" rowid in (".(count($tasksListId)?join(',',array_keys($tasksListId)):'0').")";
|
||||
$objectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,0);
|
||||
$projectstatic->next_prev_filter=" rowid in (".(count($objectsListId)?join(',',array_keys($objectsListId)):'0').")";
|
||||
}
|
||||
|
||||
dol_banner_tab($projectstatic, 'project_ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
@ -245,7 +200,7 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<br>';
|
||||
}
|
||||
|
||||
$head=task_prepare_head($task);
|
||||
$head=task_prepare_head($object);
|
||||
|
||||
/*
|
||||
* Fiche tache en mode visu
|
||||
@ -263,9 +218,9 @@ if ($id > 0 || ! empty($ref))
|
||||
if (! GETPOST('withproject') || empty($projectstatic->id))
|
||||
{
|
||||
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
|
||||
$task->next_prev_filter=" fk_projet in (".$projectsListId.")";
|
||||
$object->next_prev_filter=" fk_projet in (".$projectsListId.")";
|
||||
}
|
||||
else $task->next_prev_filter=" fk_projet = ".$projectstatic->id;
|
||||
else $object->next_prev_filter=" fk_projet = ".$projectstatic->id;
|
||||
|
||||
$morehtmlref='';
|
||||
|
||||
@ -285,7 +240,7 @@ if ($id > 0 || ! empty($ref))
|
||||
$morehtmlref.='</div>';
|
||||
}
|
||||
|
||||
dol_banner_tab($task, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
|
||||
dol_banner_tab($object, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref, $param);
|
||||
|
||||
print '<div class="fichecenter">';
|
||||
|
||||
@ -293,8 +248,8 @@ if ($id > 0 || ! empty($ref))
|
||||
print '<table class="border" width="100%">';
|
||||
|
||||
// Nb comments
|
||||
print '<td class="titlefield">'.$langs->trans("TaskNbComments").'</td><td>';
|
||||
print $task->getNbComments();
|
||||
print '<td class="titlefield">'.$langs->trans("NbComments").'</td><td>';
|
||||
print $object->getNbComments();
|
||||
print '</td></tr>';
|
||||
|
||||
// Other attributes
|
||||
@ -308,102 +263,9 @@ if ($id > 0 || ! empty($ref))
|
||||
|
||||
dol_fiche_end();
|
||||
|
||||
|
||||
print '<br>';
|
||||
print '<div id="comment">';
|
||||
|
||||
// Add comment
|
||||
|
||||
print '<form method="POST" action="'.$_SERVER["PHP_SELF"].'?id='.$task->id.'">';
|
||||
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
||||
print '<input type="hidden" name="action" value="addcomment">';
|
||||
print '<input type="hidden" name="id" value="'.$task->id.'">';
|
||||
print '<input type="hidden" name="withproject" value="'.$withproject.'">';
|
||||
|
||||
print '<table class="noborder nohover" width="100%">';
|
||||
|
||||
print '<tr class="liste_titre">';
|
||||
print '<td width="25%">'.$langs->trans("Comments").'</td>';
|
||||
print '<td width="25%"></td>';
|
||||
print '<td width="25%"></td>';
|
||||
print '<td width="25%"></td>';
|
||||
print "</tr>\n";
|
||||
|
||||
print '<tr class="oddeven">';
|
||||
print '<td></td>';
|
||||
|
||||
// Description
|
||||
print '<td colspan="2">';
|
||||
|
||||
$desc = ($_POST['comment_description']?$_POST['comment_description']:'');
|
||||
|
||||
$doleditor = new DolEditor('comment_description', $desc, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '100%');
|
||||
print $doleditor->Create(1);
|
||||
|
||||
print '</td>';
|
||||
|
||||
print '<td align="center">';
|
||||
print '<input type="submit" class="button" value="'.$langs->trans("Add").'">';
|
||||
print '</td></tr>';
|
||||
print '</table></form>';
|
||||
|
||||
// List of comments
|
||||
if(!empty($task->comments)) {
|
||||
// Default color for current user
|
||||
$TColors = array($user->id => array('bgcolor'=>'efefef','color'=>'555'));
|
||||
$first = true;
|
||||
foreach($task->comments as $comment) {
|
||||
$fk_user = $comment->fk_user;
|
||||
$userstatic->fetch($fk_user);
|
||||
if(empty($TColors[$fk_user])) {
|
||||
$bgcolor = random_color(180,240);
|
||||
if(!empty($userstatic->color)) {
|
||||
$bgcolor = $userstatic->color;
|
||||
}
|
||||
$color = (colorIsLight($bgcolor))?'555':'fff';
|
||||
$TColors[$fk_user] = array('bgcolor'=>$bgcolor,'color'=>$color);
|
||||
}
|
||||
print '<div class="width100p" style="color:#'.$TColors[$fk_user]['color'].'">';
|
||||
if($comment->fk_user == $user->id) {
|
||||
print '<div class="width25p float"> </div>';
|
||||
}
|
||||
|
||||
print '<div class="width75p float comment comment-table" style="background-color:#'.$TColors[$fk_user]['bgcolor'].'">';
|
||||
print '<div class="comment-info comment-cell">';
|
||||
if (! empty($user->photo))
|
||||
{
|
||||
print Form::showphoto('userphoto', $userstatic, 80, 0, 0, '', 'small', 0, 1).'<br/>';
|
||||
}
|
||||
print $langs->trans('User').' : '.$userstatic->getNomUrl().'<br/>';
|
||||
print $langs->trans('Date').' : '.dol_print_date($comment->datec,'dayhoursec');
|
||||
print '</div>'; // End comment-info
|
||||
|
||||
print '<div class="comment-cell comment-right">';
|
||||
print '<div class="comment-table width100p">';
|
||||
print '<div class="comment-description comment-cell">';
|
||||
print $comment->description;
|
||||
print '</div>'; // End comment-description
|
||||
if(($first && $fk_user == $user->id) || $user->admin == 1) {
|
||||
print '<a class="comment-delete comment-cell" href="'.DOL_URL_ROOT.'/projet/tasks/comment.php?action=deletecomment&id='.$id.'&withproject=1&idcomment='.$comment->id.'" title="'.$langs->trans('Delete').'">';
|
||||
print img_picto('', 'delete.png');
|
||||
print '</a>';
|
||||
}
|
||||
print '</div>'; // End comment-table
|
||||
print '</div>'; // End comment-right
|
||||
print '</div>'; // End comment
|
||||
|
||||
if($comment->fk_user != $user->id) {
|
||||
print '<div class="width25p float"> </div>';
|
||||
}
|
||||
print '<div class="clearboth"></div>';
|
||||
print '</div>'; // end 100p
|
||||
|
||||
$first = false;
|
||||
}
|
||||
}
|
||||
|
||||
print '<br>';
|
||||
print '</div>';
|
||||
|
||||
// Include comment tpl view
|
||||
include DOL_DOCUMENT_ROOT . '/core/tpl/bloc_comment.tpl.php';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -155,30 +155,32 @@ if ($socid > 0)
|
||||
}
|
||||
|
||||
|
||||
print '<div class="tabsAction">';
|
||||
//print '<div class="tabsAction">';
|
||||
//print '</div>';
|
||||
|
||||
|
||||
$morehtmlcenter='';
|
||||
if (! empty($conf->agenda->enabled))
|
||||
{
|
||||
if (! empty($user->rights->agenda->myactions->create) || ! empty($user->rights->agenda->allactions->create))
|
||||
{
|
||||
print '<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
|
||||
$morehtmlcenter.='<a class="butAction" href="'.DOL_URL_ROOT.'/comm/action/card.php?action=create'.$out.'">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
else
|
||||
{
|
||||
print '<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
$morehtmlcenter.='<a class="butActionRefused" href="#">'.$langs->trans("AddAction").'</a>';
|
||||
}
|
||||
}
|
||||
|
||||
print '</div>';
|
||||
|
||||
if (! empty($conf->agenda->enabled) && (!empty($user->rights->agenda->myactions->read) || !empty($user->rights->agenda->allactions->read) ))
|
||||
{
|
||||
print '<br>';
|
||||
|
||||
$param='&socid='.$socid;
|
||||
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("ActionsOnCompany"),'','');
|
||||
print_barre_liste($langs->trans("ActionsOnCompany"), 0, $_SERVER["PHP_SELF"], '', $sortfield, $sortorder, $morehtmlcenter, 0, -1, '', '', '', '', 0, 1, 1);
|
||||
|
||||
// List of all actions
|
||||
$filters=array();
|
||||
|
||||
@ -2532,12 +2532,16 @@ else
|
||||
|
||||
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
|
||||
|
||||
$MAX = 5;
|
||||
$MAX = 10;
|
||||
|
||||
$morehtmlright = '<a href="'.DOL_URL_ROOT.'/societe/agenda.php?socid='.$object->id.'">';
|
||||
$morehtmlright.= $langs->trans("SeeAll");
|
||||
$morehtmlright.= '</a>';
|
||||
|
||||
// List of actions on element
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||
$formactions = new FormActions($db);
|
||||
$somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAX); // Show all action for thirdparty
|
||||
$somethingshown = $formactions->showactions($object, '', $socid, 1, '', $MAX, '', $morehtmlright); // Show all action for thirdparty
|
||||
|
||||
print '</div></div></div>';
|
||||
}
|
||||
|
||||
@ -18,6 +18,7 @@
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
//require_once DOL_DOCUMENT_ROOT . '/contact/class/contact.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
/**
|
||||
* API class for contacts
|
||||
@ -333,9 +334,25 @@ class Contacts extends DolibarrApi
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
|
||||
$categories = new Categories();
|
||||
return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'contact', $id);
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$categories = new Categorie($this->db);
|
||||
|
||||
$result = $categories->getListForItem($id, 'contact', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -17,19 +17,20 @@
|
||||
|
||||
use Luracast\Restler\RestException;
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/categories/class/categorie.class.php';
|
||||
|
||||
/**
|
||||
* API class for thirdparties
|
||||
*
|
||||
* @access protected
|
||||
* @access protected
|
||||
* @class DolibarrApiAccess {@requires user,external}
|
||||
*
|
||||
*
|
||||
*/
|
||||
class Thirdparties extends DolibarrApi
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
* @var array $FIELDS Mandatory fields, checked when create and update object
|
||||
*/
|
||||
static $FIELDS = array(
|
||||
'name'
|
||||
@ -48,7 +49,7 @@ class Thirdparties extends DolibarrApi
|
||||
global $db, $conf;
|
||||
$this->db = $db;
|
||||
$this->company = new Societe($this->db);
|
||||
|
||||
|
||||
if (! empty($conf->global->SOCIETE_EMAIL_MANDATORY)) {
|
||||
static::$FIELDS[] = 'email';
|
||||
}
|
||||
@ -61,20 +62,20 @@ class Thirdparties extends DolibarrApi
|
||||
*
|
||||
* @param int $id ID of thirdparty
|
||||
* @return array|mixed data without useless information
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function get($id)
|
||||
{
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -84,14 +85,14 @@ class Thirdparties extends DolibarrApi
|
||||
|
||||
/**
|
||||
* List thirdparties
|
||||
*
|
||||
*
|
||||
* Get a list of thirdparties
|
||||
*
|
||||
*
|
||||
* @param string $sortfield Sort field
|
||||
* @param string $sortorder Sort order
|
||||
* @param int $limit Limit for list
|
||||
* @param int $page Page number
|
||||
* @param int $mode Set to 1 to show only customers
|
||||
* @param int $mode Set to 1 to show only customers
|
||||
* Set to 2 to show only prospects
|
||||
* Set to 3 to show only those are not customer neither prospect
|
||||
* @param string $sqlfilters Other criteria to filter answers separated by a comma. Syntax example "(t.ref:like:'SO-%') and (t.date_creation:<:'20160101')"
|
||||
@ -99,12 +100,12 @@ class Thirdparties extends DolibarrApi
|
||||
*/
|
||||
function index($sortfield = "t.rowid", $sortorder = 'ASC', $limit = 0, $page = 0, $mode=0, $sqlfilters = '') {
|
||||
global $db, $conf;
|
||||
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
|
||||
// case of external user, we force socids
|
||||
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : '';
|
||||
|
||||
|
||||
// If the internal user must only see his customers, force searching by him
|
||||
$search_sale = 0;
|
||||
if (! DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) $search_sale = DolibarrApiAccess::$user->id;
|
||||
@ -112,7 +113,7 @@ class Thirdparties extends DolibarrApi
|
||||
$sql = "SELECT t.rowid";
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql .= ", sc.fk_soc, sc.fk_user"; // We need these fields in order to filter by sale (including the case where the user can only see his prospects)
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX."societe as t";
|
||||
|
||||
|
||||
if ((!DolibarrApiAccess::$user->rights->societe->client->voir && !$socids) || $search_sale > 0) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; // We need this table joined to the select in order to filter by sale
|
||||
$sql.= ", ".MAIN_DB_PREFIX."c_stcomm as st";
|
||||
$sql.= " WHERE t.fk_stcomm = st.id";
|
||||
@ -130,7 +131,7 @@ class Thirdparties extends DolibarrApi
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
@ -139,7 +140,7 @@ class Thirdparties extends DolibarrApi
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
|
||||
if ($limit) {
|
||||
@ -175,7 +176,7 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
return $obj_ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create thirdparty object
|
||||
*
|
||||
@ -189,13 +190,13 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
// Check mandatory fields
|
||||
$result = $this->_validate($request_data);
|
||||
|
||||
|
||||
foreach($request_data as $field => $value) {
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
if ($this->company->create(DolibarrApiAccess::$user) < 0)
|
||||
throw new RestException(500, 'Error creating thirdparty', array_merge(array($this->company->error), $this->company->errors));
|
||||
|
||||
|
||||
return $this->company->id;
|
||||
}
|
||||
|
||||
@ -203,20 +204,20 @@ class Thirdparties extends DolibarrApi
|
||||
* Update thirdparty
|
||||
*
|
||||
* @param int $id Id of thirdparty to update
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
* @param array $request_data Datas
|
||||
* @return int
|
||||
*/
|
||||
function put($id, $request_data = NULL)
|
||||
{
|
||||
if(! DolibarrApiAccess::$user->rights->societe->creer) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->company->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Thirdparty not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('societe',$this->company->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
@ -225,13 +226,13 @@ class Thirdparties extends DolibarrApi
|
||||
if ($field == 'id') continue;
|
||||
$this->company->$field = $value;
|
||||
}
|
||||
|
||||
|
||||
if($this->company->update($id, DolibarrApiAccess::$user,1,'','','update'))
|
||||
return $this->get ($id);
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete thirdparty
|
||||
*
|
||||
@ -252,7 +253,7 @@ class Thirdparties extends DolibarrApi
|
||||
}
|
||||
return $this->company->delete($id);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get categories for a thirdparty
|
||||
*
|
||||
@ -266,9 +267,25 @@ class Thirdparties extends DolibarrApi
|
||||
*
|
||||
* @url GET {id}/categories
|
||||
*/
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0) {
|
||||
$categories = new Categories();
|
||||
return $categories->getListForItem($sortfield, $sortorder, $limit, $page, 'customer', $id);
|
||||
function getCategories($id, $sortfield = "s.rowid", $sortorder = 'ASC', $limit = 0, $page = 0)
|
||||
{
|
||||
if (! DolibarrApiAccess::$user->rights->categorie->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
$categories = new Categorie($this->db);
|
||||
|
||||
$result = $categories->getListForItem($id, 'customer', $sortfield, $sortorder, $limit, $page);
|
||||
|
||||
if (empty($result)) {
|
||||
throw new RestException(404, 'No category found');
|
||||
}
|
||||
|
||||
if ($result < 0) {
|
||||
throw new RestException(503, 'Error when retrieve category list : '.$categories->error);
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -318,24 +335,24 @@ class Thirdparties extends DolibarrApi
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object) {
|
||||
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
|
||||
unset($object->total_ht);
|
||||
unset($object->total_tva);
|
||||
unset($object->total_localtax1);
|
||||
unset($object->total_localtax2);
|
||||
unset($object->total_ttc);
|
||||
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate fields before create or update object
|
||||
*
|
||||
*
|
||||
* @param array $data Datas to validate
|
||||
* @return array
|
||||
*
|
||||
*
|
||||
* @throws RestException
|
||||
*/
|
||||
function _validate($data)
|
||||
|
||||
@ -269,7 +269,7 @@ input.select2-input {
|
||||
|
||||
.liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
|
||||
.liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month], .liste_titre select[name=month],
|
||||
.liste_titre input[name=month_lim] {
|
||||
.liste_titre input[name=month_lim], .liste_titre input[name=month_create] {
|
||||
margin-right: 4px;
|
||||
}
|
||||
input[type=submit] {
|
||||
@ -2063,7 +2063,7 @@ div.tabBar {
|
||||
background: rgb(<?php echo $colorbacktabcard1; ?>);
|
||||
}
|
||||
div.tabBar div.titre {
|
||||
padding-top: 10px;
|
||||
padding-top: 20px;
|
||||
}
|
||||
|
||||
div.tabBarWithBottom {
|
||||
|
||||
@ -284,7 +284,7 @@ textarea.cke_source:focus
|
||||
|
||||
.liste_titre input[name=monthvalid], .liste_titre input[name=search_ordermonth], .liste_titre input[name=search_deliverymonth],
|
||||
.liste_titre input[name=search_smonth], .liste_titre input[name=search_month], .liste_titre input[name=search_emonth], .liste_titre input[name=smonth], .liste_titre input[name=month],
|
||||
.liste_titre input[name=month_lim] {
|
||||
.liste_titre input[name=month_lim], .liste_titre input[name=month_create] {
|
||||
margin-right: 4px;
|
||||
}
|
||||
input, input.flat, textarea, textarea.flat, form.flat select, select, select.flat, .dataTables_length label select {
|
||||
|
||||
@ -2109,8 +2109,8 @@ class User extends CommonObject
|
||||
if (! empty($_SESSION["disablemodules"])) $label.= '<br><b>'.$langs->trans("DisabledModules").':</b> <br>'.join(', ',explode(',',$_SESSION["disablemodules"]));
|
||||
}
|
||||
|
||||
if ($option == 'leave') $url.= DOL_URL_ROOT.'/holiday/list.php?id='.$this->id;
|
||||
else $link.= $url.= DOL_URL_ROOT.'/user/card.php?id='.$this->id;
|
||||
$url = DOL_URL_ROOT.'/user/card.php?id='.$this->id;
|
||||
if ($option == 'leave') $url = DOL_URL_ROOT.'/holiday/list.php?id='.$this->id;
|
||||
|
||||
if ($option != 'nolink')
|
||||
{
|
||||
|
||||
@ -1861,7 +1861,6 @@ function dolSaveHtmlHeader($filehtmlheader, $htmlheadercontent)
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtmlheader, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
@ -1887,14 +1886,13 @@ function dolSaveCssFile($filecss, $csscontent)
|
||||
if (! empty($conf->global->MAIN_UMASK))
|
||||
@chmod($filecss, octdec($conf->global->MAIN_UMASK));
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
if (! $result)
|
||||
{
|
||||
setEventMessages('Failed to write file '.$filecss, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1917,7 +1915,6 @@ function dolSaveRobotFile($filerobot, $robotcontent)
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filerobot, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
@ -1945,7 +1942,6 @@ function dolSaveHtaccessFile($filehtaccess, $htaccess)
|
||||
|
||||
if (! $result)
|
||||
{
|
||||
$error++;
|
||||
setEventMessages('Failed to write file '.$filehtaccess, null, 'errors');
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -69,7 +69,7 @@ $required_fields = array(
|
||||
);
|
||||
|
||||
// Remove from required_fields all entries not configured in LDAP (empty) and duplicated
|
||||
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElement")));
|
||||
$required_fields=array_unique(array_values(array_filter($required_fields, "dolValidElementType")));
|
||||
|
||||
|
||||
if (! isset($argv[1])) {
|
||||
@ -214,7 +214,7 @@ exit($error);
|
||||
* @param string $element Value to test
|
||||
* @return boolean True of false
|
||||
*/
|
||||
function dolValidElement($element)
|
||||
function dolValidElementType($element)
|
||||
{
|
||||
return (trim($element) != '');
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user