Merge branch '5.0' of https://github.com/Dolibarr/dolibarr into 5.0
This commit is contained in:
commit
9b74a632e1
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/* Copyright (C) 2008-2014 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
* Copyright (C) 2017 Nicolas ZABOURI <info@inovea-conseil.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
|
||||
@ -649,7 +650,7 @@ foreach ($skeletonfiles as $skeletonfile => $outfile)
|
||||
{
|
||||
if ($prop['field'] != 'rowid' && $prop['field'] != 'id' && ! $prop['istime'])
|
||||
{
|
||||
$varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td>\$object->".$prop['field']."</td></tr>';\n";
|
||||
$varprop.="print '<tr><td class=\"fieldrequired\">'.\$langs->trans(\"Field".$prop['field']."\").'</td><td>'.\$object->".$prop['field'].".'</td></tr>';\n";
|
||||
}
|
||||
}
|
||||
$targetcontent=preg_replace('/LIST_OF_TD_LABEL_FIELDS_VIEW/', $varprop, $targetcontent);
|
||||
|
||||
@ -297,9 +297,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
||||
{
|
||||
$res = $object->fetch_optionals($object->id, $extralabels);
|
||||
|
||||
$head = commande_prepare_head($object);
|
||||
dol_fiche_head($head, 'order', $langs->trans("CustomerOrder"), 0, 'order');
|
||||
|
||||
|
||||
print load_fiche_titre($langs->trans("MyModule"));
|
||||
|
||||
dol_fiche_head();
|
||||
|
||||
@ -1196,7 +1196,7 @@ if ($id > 0)
|
||||
$out.=img_picto($langs->trans("ViewCal"),'object_calendar','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_month&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewCal").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewWeek"),'object_calendarweek','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_week&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewWeek").'</a>';
|
||||
$out.=img_picto($langs->trans("ViewDay"),'object_calendarday','class="hideonsmartphone pictoactionview"');
|
||||
$out.='<a href="'.DOL_URL_ROOT.'/comm/action/index.php?action=show_day&year='.dol_print_date($object->datep,'%Y').'&month='.dol_print_date($object->datep,'%m').'&day='.dol_print_date($object->datep,'%d').'">'.$langs->trans("ViewDay").'</a>';
|
||||
$linkback.=$out;
|
||||
|
||||
@ -54,7 +54,7 @@ class Facture extends CommonInvoice
|
||||
public $fk_element = 'fk_facture';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
public $picto='bill';
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -243,7 +243,7 @@ class Facture extends CommonInvoice
|
||||
if (! $this->mode_reglement_id) $this->mode_reglement_id = 0;
|
||||
$this->brouillon = 1;
|
||||
if (empty($this->entity)) $this->entity = $conf->entity;
|
||||
|
||||
|
||||
// Multicurrency (test on $this->multicurrency_tx because we sould take the default rate only if not using origin rate)
|
||||
if (!empty($this->multicurrency_code) && empty($this->multicurrency_tx)) list($this->fk_multicurrency,$this->multicurrency_tx) = MultiCurrency::getIdAndTxFromCode($this->db, $this->multicurrency_code);
|
||||
else $this->fk_multicurrency = MultiCurrency::getIdFromCode($this->db, $this->multicurrency_code);
|
||||
@ -286,7 +286,7 @@ class Facture extends CommonInvoice
|
||||
|
||||
$this->socid = $_facrec->socid; // Invoice created on same thirdparty than template
|
||||
$this->entity = $_facrec->entity; // Invoice created in same entity than template
|
||||
|
||||
|
||||
// Fields coming from GUI (priority on template). TODO Value of template should be used as default value on GUI so we can use here always value from GUI
|
||||
$this->fk_project = GETPOST('projectid','int') > 0 ? GETPOST('projectid','int') : $_facrec->fk_project;
|
||||
$this->note_public = GETPOST('note_public') ? GETPOST('note_public') : $_facrec->note_public;
|
||||
@ -299,7 +299,7 @@ class Facture extends CommonInvoice
|
||||
// Set here to have this defined for substitution into notes, should be recalculated after adding lines to get same result
|
||||
$this->total_ht = $_facrec->total_ht;
|
||||
$this->total_ttc = $_facrec->total_ttc;
|
||||
|
||||
|
||||
// Fields always coming from template
|
||||
$this->remise_absolue = $_facrec->remise_absolue;
|
||||
$this->remise_percent = $_facrec->remise_percent;
|
||||
@ -358,10 +358,10 @@ class Facture extends CommonInvoice
|
||||
'__INVOICE_YEAR__' => dol_print_date($this->date, '%Y'),
|
||||
'__INVOICE_NEXT_YEAR__' => dol_print_date(dol_time_plus_duree($this->date, 1, 'y'), '%Y'),
|
||||
);
|
||||
|
||||
|
||||
$substitutionisok=true;
|
||||
complete_substitutions_array($substitutionarray, $outputlangs);
|
||||
|
||||
|
||||
$this->note_public=make_substitutions($this->note_public,$substitutionarray);
|
||||
$this->note_private=make_substitutions($this->note_private,$substitutionarray);
|
||||
}
|
||||
@ -470,7 +470,7 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $error && $this->id && ! empty($conf->global->MAIN_PROPAGATE_CONTACTS_FROM_ORIGIN) && ! empty($this->origin) && ! empty($this->origin_id)) // Get contact from origin object
|
||||
{
|
||||
$originforcontact = $this->origin;
|
||||
@ -481,7 +481,7 @@ class Facture extends CommonInvoice
|
||||
$exp = new Expedition($this->db);
|
||||
$exp->fetch($this->origin_id);
|
||||
$exp->fetchObjectLinked();
|
||||
if (count($exp->linkedObjectsIds['commande']) > 0)
|
||||
if (count($exp->linkedObjectsIds['commande']) > 0)
|
||||
{
|
||||
foreach ($exp->linkedObjectsIds['commande'] as $key => $value)
|
||||
{
|
||||
@ -491,10 +491,10 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$sqlcontact = "SELECT ctc.code, ctc.source, ec.fk_socpeople FROM ".MAIN_DB_PREFIX."element_contact as ec, ".MAIN_DB_PREFIX."c_type_contact as ctc";
|
||||
$sqlcontact.= " WHERE element_id = ".$originidforcontact." AND ec.fk_c_type_contact = ctc.rowid AND ctc.element = '".$originforcontact."'";
|
||||
|
||||
|
||||
$resqlcontact = $this->db->query($sqlcontact);
|
||||
if ($resqlcontact)
|
||||
{
|
||||
@ -553,11 +553,11 @@ class Facture extends CommonInvoice
|
||||
foreach ($this->lines as $i => $val)
|
||||
{
|
||||
$line = $this->lines[$i];
|
||||
|
||||
|
||||
// Test and convert into object this->lines[$i]. When coming from REST API, we may still have an array
|
||||
//if (! is_object($line)) $line=json_decode(json_encode($line), FALSE); // convert recursively array into object.
|
||||
if (! is_object($line)) $line = (object) $line;
|
||||
|
||||
|
||||
if (($line->info_bits & 0x01) == 0) // We keep only lines with first bit = 0
|
||||
{
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
@ -1058,7 +1058,7 @@ class Facture extends CommonInvoice
|
||||
if ($this->type == self::TYPE_CREDIT_NOTE) $picto.='a'; // Credit note
|
||||
if ($this->type == self::TYPE_DEPOSIT) $picto.='d'; // Deposit invoice
|
||||
$label='';
|
||||
|
||||
|
||||
if ($user->rights->facture->lire) {
|
||||
$label = '<u>' . $langs->trans("ShowInvoice") . '</u>';
|
||||
if (! empty($this->ref))
|
||||
@ -1077,7 +1077,7 @@ class Facture extends CommonInvoice
|
||||
if ($this->type == self::TYPE_SITUATION) $label=$langs->transnoentitiesnoconv("ShowInvoiceSituation").': '.$this->ref;
|
||||
if ($moretitle) $label.=' - '.$moretitle;
|
||||
}
|
||||
|
||||
|
||||
$linkclose='';
|
||||
if (empty($notooltip) && $user->rights->facture->lire)
|
||||
{
|
||||
@ -1111,7 +1111,7 @@ class Facture extends CommonInvoice
|
||||
$result.='</span>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1319,7 +1319,7 @@ class Facture extends CommonInvoice
|
||||
$line->qty = $objp->qty;
|
||||
$line->subprice = $objp->subprice;
|
||||
|
||||
$line->vat_src_code = $objp->vat_src_code;
|
||||
$line->vat_src_code = $objp->vat_src_code;
|
||||
$line->tva_tx = $objp->tva_tx;
|
||||
$line->localtax1_tx = $objp->localtax1_tx;
|
||||
$line->localtax2_tx = $objp->localtax2_tx;
|
||||
@ -1572,7 +1572,7 @@ class Facture extends CommonInvoice
|
||||
$arraytmp=$formmargin->getMarginInfosArray($srcinvoice, false);
|
||||
$facligne->pa_ht = $arraytmp['pa_total'];
|
||||
}
|
||||
|
||||
|
||||
$facligne->total_ht = -$remise->amount_ht;
|
||||
$facligne->total_tva = -$remise->amount_tva;
|
||||
$facligne->total_ttc = -$remise->amount_ttc;
|
||||
@ -1626,7 +1626,7 @@ class Facture extends CommonInvoice
|
||||
function set_ref_client($ref_client, $notrigger=0)
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
||||
$error=0;
|
||||
|
||||
$this->db->begin();
|
||||
@ -2455,7 +2455,7 @@ class Facture extends CommonInvoice
|
||||
if (! isset($situation_percent) || $situation_percent > 100 || (string) $situation_percent == '') $situation_percent = 100;
|
||||
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva, 0, $this->thirdparty, $mysoc);
|
||||
|
||||
|
||||
// Clean vat code
|
||||
$vat_src_code='';
|
||||
if (preg_match('/\((.*)\)/', $txtva, $reg))
|
||||
@ -2463,7 +2463,7 @@ class Facture extends CommonInvoice
|
||||
$vat_src_code = $reg[1];
|
||||
$txtva = preg_replace('/\s*\(.*\)/', '', $txtva); // Remove code into vatrate.
|
||||
}
|
||||
|
||||
|
||||
$remise_percent=price2num($remise_percent);
|
||||
$qty=price2num($qty);
|
||||
$pu_ht=price2num($pu_ht);
|
||||
@ -2648,7 +2648,7 @@ class Facture extends CommonInvoice
|
||||
* @param double $pu_ht_devise Unit price in currency
|
||||
* @return int < 0 if KO, > 0 if OK
|
||||
*/
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=0, $fk_unit = null, $pu_ht_devise = 0)
|
||||
function updateline($rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1=0, $txlocaltax2=0, $price_base_type='HT', $info_bits=0, $type= self::TYPE_STANDARD, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_options=0, $situation_percent=100, $fk_unit = null, $pu_ht_devise = 0)
|
||||
{
|
||||
global $conf,$user;
|
||||
// Deprecation warning
|
||||
@ -2768,14 +2768,14 @@ class Facture extends CommonInvoice
|
||||
$this->line->label = $label;
|
||||
$this->line->desc = $desc;
|
||||
$this->line->qty = ($this->type==self::TYPE_CREDIT_NOTE?abs($qty):$qty); // For credit note, quantity is always positive and unit price negative
|
||||
|
||||
|
||||
$this->line->vat_src_code = $vat_src_code;
|
||||
$this->line->tva_tx = $txtva;
|
||||
$this->line->localtax1_tx = $txlocaltax1;
|
||||
$this->line->localtax2_tx = $txlocaltax2;
|
||||
$this->line->localtax1_type = $localtaxes_type[0];
|
||||
$this->line->localtax2_type = $localtaxes_type[2];
|
||||
|
||||
|
||||
$this->line->remise_percent = $remise_percent;
|
||||
$this->line->subprice = ($this->type==2?-abs($pu_ht):$pu_ht); // For credit note, unit price always negative, always positive otherwise
|
||||
$this->line->date_start = $date_start;
|
||||
@ -2894,7 +2894,7 @@ class Facture extends CommonInvoice
|
||||
function deleteline($rowid)
|
||||
{
|
||||
global $user;
|
||||
|
||||
|
||||
dol_syslog(get_class($this)."::deleteline rowid=".$rowid, LOG_DEBUG);
|
||||
|
||||
if (! $this->brouillon)
|
||||
@ -2920,13 +2920,13 @@ class Facture extends CommonInvoice
|
||||
}
|
||||
|
||||
$line=new FactureLigne($this->db);
|
||||
|
||||
|
||||
$line->context = $this->context;
|
||||
|
||||
// For triggers
|
||||
$result = $line->fetch($rowid);
|
||||
if (! ($result > 0)) dol_print_error($db, $line->error, $line->errors);
|
||||
|
||||
|
||||
if ($line->delete($user) > 0)
|
||||
{
|
||||
$result=$this->update_price(1);
|
||||
@ -4340,7 +4340,7 @@ class FactureLigne extends CommonInvoiceLine
|
||||
$this->fk_unit = $objp->fk_unit;
|
||||
$this->fk_user_modif = $objp->fk_user_modif;
|
||||
$this->fk_user_author = $objp->fk_user_author;
|
||||
|
||||
|
||||
$this->situation_percent = $objp->situation_percent;
|
||||
$this->fk_prev_id = $objp->fk_prev_id;
|
||||
|
||||
|
||||
@ -252,7 +252,7 @@ class BonPrelevement extends CommonObject
|
||||
function getErrorString($error)
|
||||
{
|
||||
global $langs;
|
||||
|
||||
|
||||
$errors = array();
|
||||
|
||||
$errors[1027] = $langs->trans("DateInvalid");
|
||||
@ -813,7 +813,7 @@ class BonPrelevement extends CommonObject
|
||||
dol_syslog(__METHOD__."::Read invoices error ".$this->db->error(), LOG_ERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT . '/societe/class/companybankaccount.class.php';
|
||||
@ -834,7 +834,7 @@ class BonPrelevement extends CommonObject
|
||||
{
|
||||
$bac = new CompanyBankAccount($this->db);
|
||||
$bac->fetch(0,$soc->id);
|
||||
|
||||
|
||||
if ($bac->verif() >= 1)
|
||||
//if (true)
|
||||
{
|
||||
@ -867,7 +867,7 @@ class BonPrelevement extends CommonObject
|
||||
}
|
||||
|
||||
$ok=0;
|
||||
|
||||
|
||||
// Withdraw invoices in factures_prev array
|
||||
$out=count($factures_prev)." invoices will be withdrawn.";
|
||||
//print $out."\n";
|
||||
@ -920,7 +920,7 @@ class BonPrelevement extends CommonObject
|
||||
|
||||
$dir=$conf->prelevement->dir_output.'/receipts';
|
||||
if (! is_dir($dir)) dol_mkdir($dir);
|
||||
|
||||
|
||||
$this->filename = $dir.'/'.$ref.'.xml';
|
||||
|
||||
// Create withdraw receipt in database
|
||||
@ -1028,7 +1028,7 @@ class BonPrelevement extends CommonObject
|
||||
$this->emetteur_bic = $account->bic;
|
||||
|
||||
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
||||
|
||||
|
||||
$this->raison_sociale = $account->proprio;
|
||||
}
|
||||
|
||||
@ -1272,16 +1272,6 @@ class BonPrelevement extends CommonObject
|
||||
* section Debiteur (sepa Debiteurs bloc lines)
|
||||
*/
|
||||
|
||||
/*$tmp_invoices = array();
|
||||
|
||||
$sql = "SELECT f.facnumber as fac FROM ".MAIN_DB_PREFIX."prelevement_lignes as pl, ".MAIN_DB_PREFIX."facture as f, ".MAIN_DB_PREFIX."prelevement_facture as pf, ".MAIN_DB_PREFIX."societe as soc, ".MAIN_DB_PREFIX."c_country as p, ".MAIN_DB_PREFIX."societe_rib as rib WHERE pl.fk_prelevement_bons = ".$this->id." AND pl.rowid = pf.fk_prelevement_lignes AND pf.fk_facture = f.rowid AND soc.fk_pays = p.rowid AND soc.rowid = f.fk_soc AND rib.fk_soc = f.fk_soc AND rib.default_rib = 1";
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql) {
|
||||
while ($objfac = $this->db->fetch_object($resql)) {
|
||||
$tmp_invoices[] = $objfac->fac;
|
||||
}
|
||||
}*/
|
||||
|
||||
$sql = "SELECT soc.code_client as code, soc.address, soc.zip, soc.town, c.code as country_code,";
|
||||
$sql.= " pl.client_nom as nom, pl.code_banque as cb, pl.code_guichet as cg, pl.number as cc, pl.amount as somme,";
|
||||
$sql.= " f.facnumber as fac, pf.fk_facture as idfac, rib.datec, rib.iban_prefix as iban, rib.bic as bic, rib.rowid as drum";
|
||||
@ -1365,35 +1355,6 @@ class BonPrelevement extends CommonObject
|
||||
fputs($this->file, ' </PmtInf>'.$CrLf);
|
||||
fputs($this->file, ' </CstmrDrctDbtInitn>'.$CrLf);
|
||||
fputs($this->file, '</Document>'.$CrLf);
|
||||
|
||||
/*$sql = "SELECT pl.amount";
|
||||
$sql.= " FROM";
|
||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_lignes as pl,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."facture as f,";
|
||||
$sql.= " ".MAIN_DB_PREFIX."prelevement_facture as pf";
|
||||
$sql.= " WHERE pl.fk_prelevement_bons = ".$this->id;
|
||||
$sql.= " AND pl.rowid = pf.fk_prelevement_lignes";
|
||||
$sql.= " AND pf.fk_facture = f.rowid";
|
||||
|
||||
//Lines
|
||||
$i = 0;
|
||||
$resql=$this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$this->total = $this->total + $obj->amount;
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$result = -2;
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
// Build file for Other Countries with unknow format
|
||||
@ -1580,11 +1541,11 @@ class BonPrelevement extends CommonObject
|
||||
$XML_DEBITOR .=' </FinInstnId>'.$CrLf;
|
||||
$XML_DEBITOR .=' </DbtrAgt>'.$CrLf;
|
||||
$XML_DEBITOR .=' <Dbtr>'.$CrLf;
|
||||
$XML_DEBITOR .=' <Nm>'.strtoupper(dol_string_unaccent($row_nom)).'</Nm>'.$CrLf;
|
||||
$XML_DEBITOR .=' <Nm>'.dolEscapeXML(strtoupper(dol_string_unaccent($row_nom))).'</Nm>'.$CrLf;
|
||||
$XML_DEBITOR .=' <PstlAdr>'.$CrLf;
|
||||
$XML_DEBITOR .=' <Ctry>'.$row_country_code.'</Ctry>'.$CrLf;
|
||||
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))).'</AdrLine>'.$CrLf;
|
||||
$XML_DEBITOR .=' <AdrLine>'.dol_string_unaccent($row_zip.' '.$row_town).'</AdrLine>'.$CrLf;
|
||||
$XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_trunc(dol_string_unaccent(strtr($row_address, array(CHR(13) => ", ", CHR(10) => ""))),70,'right','UTF-8',true)).'</AdrLine>'.$CrLf;
|
||||
$XML_DEBITOR .=' <AdrLine>'.dolEscapeXML(dol_string_unaccent($row_zip.' '.$row_town)).'</AdrLine>'.$CrLf;
|
||||
$XML_DEBITOR .=' </PstlAdr>'.$CrLf;
|
||||
$XML_DEBITOR .=' </Dbtr>'.$CrLf;
|
||||
$XML_DEBITOR .=' <DbtrAcct>'.$CrLf;
|
||||
@ -1679,7 +1640,7 @@ class BonPrelevement extends CommonObject
|
||||
* @return string String with SEPA Sender
|
||||
*/
|
||||
function EnregEmetteurSEPA($configuration, $ladate, $nombre, $total, $CrLf='\n')
|
||||
{
|
||||
{
|
||||
// SEPA INITIALISATION
|
||||
global $conf;
|
||||
|
||||
@ -1698,12 +1659,12 @@ class BonPrelevement extends CommonObject
|
||||
$this->emetteur_number_key = $account->cle_rib;
|
||||
$this->emetteur_iban = $account->iban;
|
||||
$this->emetteur_bic = $account->bic;
|
||||
|
||||
|
||||
$this->emetteur_ics = $conf->global->PRELEVEMENT_ICS; // Ex: PRELEVEMENT_ICS = "FR78ZZZ123456";
|
||||
|
||||
|
||||
$this->raison_sociale = $account->proprio;
|
||||
}
|
||||
|
||||
|
||||
// Récupération info demandeur
|
||||
$sql = "SELECT rowid, ref";
|
||||
$sql.= " FROM";
|
||||
|
||||
@ -46,7 +46,7 @@ class Contrat extends CommonObject
|
||||
public $fk_element='fk_contrat';
|
||||
protected $ismultientitymanaged = 1; // 0=No test on entity, 1=Test with field entity, 2=Test with link by societe
|
||||
public $picto='contract';
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@ -609,7 +609,7 @@ class Contrat extends CommonObject
|
||||
|
||||
$this->lines=array();
|
||||
$pos = 0;
|
||||
|
||||
|
||||
// Selectionne les lignes contrats liees a un produit
|
||||
$sql = "SELECT p.label as product_label, p.description as product_desc, p.ref as product_ref,";
|
||||
$sql.= " d.rowid, d.fk_contrat, d.statut, d.description, d.price_ht, d.vat_src_code, d.tva_tx, d.localtax1_tx, d.localtax2_tx, d.localtax1_type, d.localtax2_type, d.qty, d.remise_percent, d.subprice, d.fk_product_fournisseur_price as fk_fournprice, d.buy_price_ht as pa_ht,";
|
||||
@ -1849,7 +1849,7 @@ class Contrat extends CommonObject
|
||||
$url = DOL_URL_ROOT.'/contrat/card.php?id='.$this->id;
|
||||
$picto = 'contract';
|
||||
$label = '';
|
||||
|
||||
|
||||
if ($user->rights->contrat->lire) {
|
||||
$label = '<u>'.$langs->trans("ShowContract").'</u>';
|
||||
$label .= '<br><b>'.$langs->trans('Ref').':</b> '.$this->ref;
|
||||
@ -1865,7 +1865,7 @@ class Contrat extends CommonObject
|
||||
$label .= '<br><b>'.$langs->trans('AmountTTC').':</b> '.price($this->total_ttc, 0, $langs, 0, -1, -1, $conf->currency);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$linkclose='';
|
||||
if (empty($notooltip) && $user->rights->contrat->lire)
|
||||
{
|
||||
@ -1881,7 +1881,7 @@ class Contrat extends CommonObject
|
||||
$linkstart = '<a href="'.$url.'"';
|
||||
$linkstart.=$linkclose.'>';
|
||||
$linkend='</a>';
|
||||
|
||||
|
||||
if ($withpicto) $result.=($linkstart.img_object(($notooltip?'':$label), $picto, ($notooltip?'':'class="classfortooltip"'), 0, 0, $notooltip?0:1).$linkend);
|
||||
if ($withpicto && $withpicto != 2) $result.=' ';
|
||||
$result.=$linkstart.$this->ref.$linkend;
|
||||
@ -2743,6 +2743,8 @@ class ContratLigne extends CommonObjectLine
|
||||
if (empty($this->total_ht)) $this->total_ht = 0;
|
||||
if (empty($this->total_tva)) $this->total_tva = 0;
|
||||
if (empty($this->total_ttc)) $this->total_ttc = 0;
|
||||
if (empty($this->localtax1_tx)) $this->localtax1_tx = 0;
|
||||
if (empty($this->localtax2_tx)) $this->localtax2_tx = 0;
|
||||
|
||||
// Check parameters
|
||||
// Put here code to add control on parameters values
|
||||
@ -2909,7 +2911,7 @@ class ContratLigne extends CommonObjectLine
|
||||
|
||||
// Insertion dans la base
|
||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."contratdet";
|
||||
$sql.= " (fk_contrat, label, description, fk_product, qty, tva_tx,";
|
||||
$sql.= " (fk_contrat, label, description, fk_product, qty, vat_src_code, tva_tx,";
|
||||
$sql.= " localtax1_tx, localtax2_tx, localtax1_type, localtax2_type, remise_percent, subprice,";
|
||||
$sql.= " total_ht, total_tva, total_localtax1, total_localtax2, total_ttc,";
|
||||
$sql.= " info_bits,";
|
||||
|
||||
@ -102,14 +102,14 @@ function getDoliDBInstance($type, $host, $user, $pass, $name, $port)
|
||||
/**
|
||||
* Get list of entity id to use
|
||||
*
|
||||
* @param string $element Current element
|
||||
* 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource',
|
||||
* @param string $element Current element
|
||||
* 'societe', 'socpeople', 'actioncomm', 'agenda', 'resource',
|
||||
* 'product', 'productprice', 'stock',
|
||||
* 'propal', 'facture', 'facture_fourn',
|
||||
* 'categorie', 'bank_account', 'bank_account', 'adherent', 'user',
|
||||
* 'categorie', 'bank_account', 'bank_account', 'adherent', 'user',
|
||||
* 'commande', 'commande_fournisseur', 'expedition', 'intervention', 'survey',
|
||||
* 'contract', 'tax', 'expensereport', 'holiday', 'multicurrency', 'project',
|
||||
* 'email_template', 'event',
|
||||
* 'email_template', 'event',
|
||||
* @param int $shared 0=Return id of entity, 1=Return id entity + shared entities
|
||||
* @return mixed Entity id(s) to use
|
||||
*/
|
||||
@ -121,7 +121,7 @@ function getEntity($element=false, $shared=0)
|
||||
if ($element == 'actioncomm') $element='agenda';
|
||||
if ($element == 'fichinter') $element='intervention';
|
||||
if ($element == 'categorie') $element='category';
|
||||
|
||||
|
||||
if (is_object($mc))
|
||||
{
|
||||
return $mc->getEntity($element, $shared);
|
||||
@ -203,7 +203,7 @@ function getBrowserInfo($user_agent)
|
||||
elseif (preg_match('/opera(\/|\s)([\d\.]*)/i', $user_agent, $reg)) { $name='opera'; $version=$reg[2]; }
|
||||
elseif (preg_match('/(MSIE\s([0-9]+\.[0-9]))|.*(Trident\/[0-9]+.[0-9];\srv:([0-9]+\.[0-9]+))/i', $user_agent, $reg)) { $name='ie'; $version=end($reg); } // MS products at end
|
||||
elseif (preg_match('/l(i|y)n(x|ks)(\(|\/|\s)*([\d\.]+)/i', $user_agent, $reg)) { $name='lynxlinks'; $version=$reg[4]; }
|
||||
|
||||
|
||||
if ($tablet) {
|
||||
$layout = 'tablet';
|
||||
} elseif ($phone) {
|
||||
@ -268,7 +268,7 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
|
||||
{
|
||||
$tmp=dol_getdate(dol_now(), true);
|
||||
$out = $tmp['mon'];
|
||||
}
|
||||
}
|
||||
elseif ($reg[1] == 'YEAR')
|
||||
{
|
||||
$tmp=dol_getdate(dol_now(), true);
|
||||
@ -280,7 +280,7 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
|
||||
$out = $mysoc->country_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
switch ($check)
|
||||
{
|
||||
case 'int':
|
||||
@ -337,13 +337,13 @@ function GETPOST($paramname,$check='',$method=0,$filter=NULL,$options=NULL)
|
||||
* This prefix is unique for instance and avoid conflict between multi-instances,
|
||||
* even when having two instances with one root dir or two instances in virtual servers
|
||||
*
|
||||
* @param string $mode '' or 'email'
|
||||
* @param string $mode '' or 'email'
|
||||
* @return string A calculated prefix
|
||||
*/
|
||||
function dol_getprefix($mode='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
// If MAIL_PREFIX_FOR_EMAIL_ID is set and prefix is for email
|
||||
if ($mode == 'email' && ! empty($conf->global->MAIL_PREFIX_FOR_EMAIL_ID))
|
||||
{
|
||||
@ -425,15 +425,15 @@ function dol_buildpath($path, $type=0)
|
||||
if ($type == 1) $res = DOL_URL_ROOT.'/'.$path; // Standard value
|
||||
if ($type == 2) $res = DOL_MAIN_URL_ROOT.'/'.$path; // Standard value
|
||||
if ($type == 3) $res = DOL_URL_ROOT.'/'.$path;
|
||||
|
||||
|
||||
foreach ($conf->file->dol_document_root as $key => $dirroot) // ex: array(["main"]=>"/home/main/htdocs", ["alt0"]=>"/home/dirmod/htdocs", ...)
|
||||
{
|
||||
if ($key == 'main')
|
||||
if ($key == 'main')
|
||||
{
|
||||
if ($type == 3)
|
||||
{
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
@ -460,12 +460,12 @@ function dol_buildpath($path, $type=0)
|
||||
if ($type == 3)
|
||||
{
|
||||
global $dolibarr_main_url_root;
|
||||
|
||||
|
||||
// Define $urlwithroot
|
||||
$urlwithouturlroot=preg_replace('/'.preg_quote(DOL_URL_ROOT,'/').'$/i','',trim($dolibarr_main_url_root));
|
||||
$urlwithroot=$urlwithouturlroot.DOL_URL_ROOT; // This is to use external domain name found into config file
|
||||
//$urlwithroot=DOL_MAIN_URL_ROOT; // This is to use same domain name than current
|
||||
|
||||
|
||||
$res=(preg_match('/^http/i',$conf->file->dol_url_root[$key])?'':$urlwithroot).$conf->file->dol_url_root[$key].'/'.$path; // Test on start with http is for old conf syntax
|
||||
}
|
||||
break;
|
||||
@ -732,13 +732,13 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
throw new Exception('Incorrect log level');
|
||||
}
|
||||
if ($level > $conf->global->SYSLOG_LEVEL) return;
|
||||
|
||||
|
||||
// If adding log inside HTML page is required
|
||||
if (! empty($_REQUEST['logtohtml']) && (! empty($conf->global->MAIN_ENABLE_LOG_TO_HTML) || ! empty($conf->global->MAIN_LOGTOHTML))) // MAIN_LOGTOHTML kept for backward compatibility
|
||||
{
|
||||
$conf->logbuffer[] = dol_print_date(time(),"%Y-%m-%d %H:%M:%S")." ".$message;
|
||||
}
|
||||
|
||||
|
||||
//TODO: Remove this. MAIN_ENABLE_LOG_INLINE_HTML should be deprecated and use a log handler dedicated to HTML output
|
||||
// If enable html log tag enabled and url parameter log defined, we show output log on HTML comments
|
||||
if (! empty($conf->global->MAIN_ENABLE_LOG_INLINE_HTML) && ! empty($_GET["log"]))
|
||||
@ -747,7 +747,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
print $message."\n";
|
||||
print "Log end -->\n";
|
||||
}
|
||||
|
||||
|
||||
$data = array(
|
||||
'message' => $message,
|
||||
'script' => (isset($_SERVER['PHP_SELF'])? basename($_SERVER['PHP_SELF'],'.php') : false),
|
||||
@ -755,7 +755,7 @@ function dol_syslog($message, $level = LOG_INFO, $ident = 0, $suffixinfilename='
|
||||
'user' => ((is_object($user) && $user->id) ? $user->login : false),
|
||||
'ip' => false
|
||||
);
|
||||
|
||||
|
||||
if (! empty($_SERVER["REMOTE_ADDR"])) $data['ip'] = $_SERVER['REMOTE_ADDR'];
|
||||
// This is when PHP session is ran inside a web server but not inside a client request (example: init code of apache)
|
||||
else if (! empty($_SERVER['SERVER_ADDR'])) $data['ip'] = $_SERVER['SERVER_ADDR'];
|
||||
@ -814,7 +814,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
|
||||
global $conf, $langs, $hookmanager;
|
||||
|
||||
if ($notab == -1) $notab = 0; // For better compatiblity with modules for 6.0
|
||||
|
||||
|
||||
$out="\n".'<div class="tabs" data-role="controlgroup" data-type="horizontal">'."\n";
|
||||
|
||||
// Show title
|
||||
@ -944,7 +944,7 @@ function dol_get_fiche_head($links=array(), $active='', $title='', $notab=0, $pi
|
||||
{
|
||||
$out = $hookmanager->resPrint;
|
||||
}
|
||||
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
@ -1003,7 +1003,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
if ($object->element == 'member') $modulepart='memberphoto';
|
||||
if ($object->element == 'user') $modulepart='userphoto';
|
||||
if ($object->element == 'product') $modulepart='product';
|
||||
|
||||
|
||||
if ($object->element == 'product')
|
||||
{
|
||||
$width=80; $cssclass='photoref';
|
||||
@ -1011,7 +1011,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
$maxvisiblephotos=(isset($conf->global->PRODUCT_MAX_VISIBLE_PHOTO)?$conf->global->PRODUCT_MAX_VISIBLE_PHOTO:5);
|
||||
if ($conf->browser->phone) $maxvisiblephotos=1;
|
||||
if ($showimage) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$object->show_photos($conf->product->multidir_output[$object->entity],'small',$maxvisiblephotos,0,0,0,$width,0).'</div>';
|
||||
else
|
||||
else
|
||||
{
|
||||
if (!empty($conf->global->PRODUCT_NODISPLAYIFNOPHOTO)) {
|
||||
$nophoto='';
|
||||
@ -1023,11 +1023,11 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if ($showimage)
|
||||
if ($showimage)
|
||||
{
|
||||
if ($modulepart != 'unknown')
|
||||
if ($modulepart != 'unknown')
|
||||
{
|
||||
$phototoshow = $form->showphoto($modulepart,$object,0,0,0,'photoref','small',1,0,$maxvisiblephotos);
|
||||
if ($phototoshow)
|
||||
@ -1040,7 +1040,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
elseif ($conf->browser->layout != 'phone') // Show No photo link (picto of pbject)
|
||||
{
|
||||
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">';
|
||||
if ($object->element == 'action')
|
||||
if ($object->element == 'action')
|
||||
{
|
||||
$cssclass='photorefcenter';
|
||||
$nophoto=img_picto('', 'title_agenda', '', false, 1);
|
||||
@ -1061,7 +1061,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
if ($showbarcode) $morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref">'.$form->showbarcode($object).'</div>';
|
||||
if ($object->element == 'societe' && ! empty($conf->use_javascript_ajax) && $user->rights->societe->creer && ! empty($conf->global->MAIN_DIRECT_STATUS_UPDATE)) {
|
||||
$morehtmlstatus.=ajax_object_onoff($object, 'status', 'status', 'InActivity', 'ActivityCeased');
|
||||
}
|
||||
}
|
||||
elseif ($object->element == 'product')
|
||||
{
|
||||
//$morehtmlstatus.=$langs->trans("Status").' ('.$langs->trans("Sell").') ';
|
||||
@ -1081,39 +1081,39 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
elseif ($object->element == 'facture' || $object->element == 'invoice' || $object->element == 'invoice_supplier')
|
||||
{
|
||||
$tmptxt=$object->getLibStatut(6, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
$morehtmlstatus.=$tmptxt;
|
||||
}
|
||||
elseif ($object->element == 'chargesociales')
|
||||
{
|
||||
$tmptxt=$object->getLibStatut(6, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
$morehtmlstatus.=$tmptxt;
|
||||
}
|
||||
elseif ($object->element == 'loan')
|
||||
{
|
||||
$tmptxt=$object->getLibStatut(6, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5, $object->totalpaye);
|
||||
$morehtmlstatus.=$tmptxt;
|
||||
}
|
||||
elseif ($object->element == 'contrat')
|
||||
elseif ($object->element == 'contrat')
|
||||
{
|
||||
if ($object->statut==0) $morehtmlstatus.=$object->getLibStatut(2);
|
||||
else $morehtmlstatus.=$object->getLibStatut(4);
|
||||
}
|
||||
else { // Generic case
|
||||
$tmptxt=$object->getLibStatut(6);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
|
||||
if (empty($tmptxt) || $tmptxt == $object->getLibStatut(3) || $conf->browser->layout=='phone') $tmptxt=$object->getLibStatut(5);
|
||||
$morehtmlstatus.=$tmptxt;
|
||||
}
|
||||
if (! empty($object->name_alias)) $morehtmlref.='<div class="refidno">'.$object->name_alias.'</div>'; // For thirdparty
|
||||
|
||||
|
||||
if ($object->element == 'product' || $object->element == 'bank_account')
|
||||
{
|
||||
if(! empty($object->label)) $morehtmlref.='<div class="refidno">'.$object->label.'</div>';
|
||||
}
|
||||
|
||||
if ($object->element != 'product' && $object->element != 'bookmark')
|
||||
if ($object->element != 'product' && $object->element != 'bookmark')
|
||||
{
|
||||
$morehtmlref.='<div class="refidno">';
|
||||
$morehtmlref.=$object->getBannerAddress('refaddress',$object);
|
||||
@ -1125,7 +1125,7 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
|
||||
$morehtmlref.=$langs->trans("TechnicalID").': '.$object->id;
|
||||
$morehtmlref.='</div>';
|
||||
}
|
||||
|
||||
|
||||
print '<div class="'.($onlybanner?'arearefnobottom ':'arearef ').'heightref valignmiddle" width="100%">';
|
||||
print $form->showrefnav($object, $paramid, $morehtml, $shownav, $fieldid, $fieldref, $morehtmlref, $moreparam, $nodbprefix, $morehtmlleft, $morehtmlstatus, $morehtmlright);
|
||||
print '</div>';
|
||||
@ -1301,9 +1301,9 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
$reduceformat=(! empty($conf->dol_optimize_smallscreen) && in_array($format,array('day','dayhour')))?1:0;
|
||||
$formatwithoutreduce = preg_replace('/reduceformat/','',$format);
|
||||
if ($formatwithoutreduce != $format) { $format = $formatwithoutreduce; $reduceformat=1; } // so format 'dayreduceformat' is processed like day
|
||||
|
||||
|
||||
// Change predefined format into computer format. If found translation in lang file we use it, otherwise we use default.
|
||||
// TODO Add format daysmallyear and dayhoursmallyear
|
||||
// TODO Add format daysmallyear and dayhoursmallyear
|
||||
if ($format == 'day') $format=($outputlangs->trans("FormatDateShort")!="FormatDateShort"?$outputlangs->trans("FormatDateShort"):$conf->format_date_short);
|
||||
else if ($format == 'hour') $format=($outputlangs->trans("FormatHourShort")!="FormatHourShort"?$outputlangs->trans("FormatHourShort"):$conf->format_hour_short);
|
||||
else if ($format == 'hourduration') $format=($outputlangs->trans("FormatHourShortDuration")!="FormatHourShortDuration"?$outputlangs->trans("FormatHourShortDuration"):$conf->format_hour_short_duration);
|
||||
@ -1375,7 +1375,8 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
|
||||
if (preg_match('/__b__/i',$format))
|
||||
{
|
||||
// Here ret is string in PHP setup language (strftime was used). Now we convert to $outputlangs.
|
||||
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Remove this
|
||||
$month=adodb_strftime('%m',$time+$offsettz+$offsetdst); // TODO Replace this with function Date PHP. We also should not use anymore offsettz and offsetdst but only offsettzstring.
|
||||
$month=sprintf("%02d", $month); // $month may be return with format '06' on some installation and '6' on other, so we force it to '06'.
|
||||
if ($encodetooutput)
|
||||
{
|
||||
$monthtext=$outputlangs->transnoentities('Month'.$month);
|
||||
@ -1805,7 +1806,7 @@ function dol_print_phone($phone,$countrycode='',$cid=0,$socid=0,$addlink='',$sep
|
||||
$newphone=($separ!=''?'(':'').substr($newphone,0,3).($separ!=''?')':'').$separ.substr($newphone,3,3).($separ!=''?'-':'').substr($newphone,6,4);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (! empty($addlink)) // Link on phone number (+ link to add action if conf->global->AGENDA_ADDACTIONFORPHONE set)
|
||||
{
|
||||
if (! empty($conf->browser->phone) || (! empty($conf->clicktodial->enabled) && ! empty($conf->global->CLICKTODIAL_USE_TEL_LINK_ON_PHONE_NUMBERS))) // If phone or option for, we use link of phone
|
||||
@ -1935,7 +1936,7 @@ function dol_user_country()
|
||||
* @param int $mode thirdparty|contact|member|other
|
||||
* @param int $id Id of object
|
||||
* @param int $noprint No output. Result is the function return
|
||||
* @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
|
||||
* @param string $charfornl Char to use instead of nl2br. '' means we use a standad nl2br.
|
||||
* @return string|void Nothing if noprint is 0, formatted address if noprint is 1
|
||||
* @see dol_format_address
|
||||
*/
|
||||
@ -1956,7 +1957,7 @@ function dol_print_address($address, $htmlid, $mode, $id, $noprint=0, $charfornl
|
||||
{
|
||||
if (empty($charfornl)) $out.=nl2br($address);
|
||||
else $out.=preg_replace('/[\r\n]+/', $charfornl, $address);
|
||||
|
||||
|
||||
$showgmap=$showomap=0;
|
||||
|
||||
// TODO Add a hook here
|
||||
@ -2084,7 +2085,7 @@ function dol_print_graph($htmlid,$width,$height,$data,$showlegend=0,$type='pie',
|
||||
print '<div class="nographyettext">'.$langs->trans("NotEnoughDataYet").'</div>';
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (empty($conf->use_javascript_ajax)) return;
|
||||
$jsgraphlib='flot';
|
||||
$datacolor=array();
|
||||
@ -2253,7 +2254,7 @@ function dol_trunc($string,$size=40,$trunc='right',$stringencoding='UTF-8',$nodo
|
||||
global $conf;
|
||||
|
||||
if ($size==0 || ! empty($conf->global->MAIN_DISABLE_TRUNC)) return $string;
|
||||
|
||||
|
||||
if (empty($stringencoding)) $stringencoding='UTF-8';
|
||||
// reduce for small screen
|
||||
if ($conf->dol_optimize_smallscreen==1 && $display==1) $size = round($size/3);
|
||||
@ -3206,7 +3207,7 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
|
||||
* @param string $options More parameters for links ('' by default, does not include sortfield neither sortorder)
|
||||
* @param string $sortfield Field to sort on ('' by default)
|
||||
* @param string $sortorder Order to sort ('' by default)
|
||||
* @param string $center String in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction()
|
||||
* @param string $center String in the middle ('' by default). We often find here string $massaction comming from $form->selectMassAction()
|
||||
* @param int $num Number of records found by select with limit+1
|
||||
* @param int|string $totalnboflines Total number of records/lines for all pages (if known). Use a negative value of number to not show number. Use '' if unknown.
|
||||
* @param string $picto Icon to use before title (should be a 32x32 transparent png file)
|
||||
@ -3220,11 +3221,11 @@ function load_fiche_titre($titre, $morehtmlright='', $picto='title_generic.png',
|
||||
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)
|
||||
{
|
||||
global $conf,$langs;
|
||||
|
||||
|
||||
$savlimit = $limit;
|
||||
$savtotalnboflines = $totalnboflines;
|
||||
$totalnboflines=abs($totalnboflines);
|
||||
|
||||
|
||||
if ($picto == 'setup') $picto='title_setup.png';
|
||||
if (($conf->browser->name == 'ie') && $picto=='title_generic.png') $picto='title.gif';
|
||||
if ($limit < 0) $limit = $conf->liste_limit;
|
||||
@ -3237,7 +3238,7 @@ function print_barre_liste($titre, $page, $file, $options='', $sortfield='', $so
|
||||
$nextpage = 0;
|
||||
}
|
||||
//print 'totalnboflines='.$totalnboflines.'-savlimit='.$savlimit.'-limit='.$limit.'-num='.$num.'-nextpage='.$nextpage;
|
||||
|
||||
|
||||
print "\n";
|
||||
print "<!-- Begin title '".$titre."' -->\n";
|
||||
print '<table width="100%" border="0" class="notopnoleftnoright'.($morecss?' '.$morecss:'').'" style="margin-bottom: 6px;"><tr>';
|
||||
@ -3338,7 +3339,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
//$pagesizechoices.=',0:'.$langs->trans("All"); // Not yet supported
|
||||
//$pagesizechoices.=',2:2';
|
||||
if (! empty($conf->global->MAIN_PAGESIZE_CHOICES)) $pagesizechoices=$conf->global->MAIN_PAGESIZE_CHOICES;
|
||||
|
||||
|
||||
print '<li class="pagination">';
|
||||
print '<select class="flat selectlimit" name="limit" title="'.dol_escape_htmltag($langs->trans("MaxNbOfRecordPerPage")).'">';
|
||||
$tmpchoice=explode(',',$pagesizechoices);
|
||||
@ -3378,7 +3379,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
</script>
|
||||
';
|
||||
}
|
||||
print '</li>';
|
||||
print '</li>';
|
||||
}
|
||||
if ($page > 0)
|
||||
{
|
||||
@ -3417,7 +3418,7 @@ function print_fleche_navigation($page, $file, $options='', $nextpage=0, $betwee
|
||||
function vatrate($rate, $addpercent=false, $info_bits=0, $usestarfornpr=0)
|
||||
{
|
||||
$morelabel='';
|
||||
|
||||
|
||||
if (preg_match('/%/',$rate))
|
||||
{
|
||||
$rate=str_replace('%','',$rate);
|
||||
@ -3620,7 +3621,7 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
|
||||
|
||||
/**
|
||||
* Output a dimension with best unit
|
||||
*
|
||||
*
|
||||
* @param float $dimension Dimension
|
||||
* @param int $unit Unit of dimension (0, -3, ...)
|
||||
* @param string $type 'weight', 'volume', ...
|
||||
@ -3632,16 +3633,16 @@ function price2num($amount,$rounding='',$alreadysqlnb=0)
|
||||
function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=-1, $forceunitoutput='no')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/product.lib.php';
|
||||
|
||||
if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
|
||||
|
||||
if (($forceunitoutput == 'no' && $dimension < 1/10000) || (is_numeric($forceunitoutput) && $forceunitoutput == -6))
|
||||
{
|
||||
$dimension = $dimension * 1000000;
|
||||
$unit = $unit - 6;
|
||||
$unit = $unit - 6;
|
||||
}
|
||||
elseif (($forceunitoutput == 'no' && $dimension < 1/10) || (is_numeric($forceunitoutput) && $forceunitoutput == -3))
|
||||
{
|
||||
$dimension = $dimension * 1000;
|
||||
$unit = $unit - 3;
|
||||
$unit = $unit - 3;
|
||||
}
|
||||
elseif (($forceunitoutput == 'no' && $dimension > 100000000) || (is_numeric($forceunitoutput) && $forceunitoutput == 6))
|
||||
{
|
||||
@ -3653,9 +3654,9 @@ function showDimensionInBestUnit($dimension, $unit, $type, $outputlangs, $round=
|
||||
$dimension = $dimension / 1000;
|
||||
$unit = $unit + 3;
|
||||
}
|
||||
|
||||
|
||||
$ret=price($dimension, 0, $outputlangs, 0, 0, $round).' '.measuring_units_string($unit, $type);
|
||||
|
||||
|
||||
return $ret;
|
||||
}
|
||||
|
||||
@ -3686,12 +3687,12 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
|
||||
$vatratecleaned = trim($reg[1]);
|
||||
$vatratecode = $reg[2];
|
||||
}
|
||||
|
||||
|
||||
/*if ($thirdparty_buyer->country_code != $thirdparty_seller->country_code)
|
||||
{
|
||||
return 0;
|
||||
}*/
|
||||
|
||||
|
||||
// Some test to guess with no need to make database access
|
||||
if ($mysoc->country_code == 'ES') // For spain localtaxes 1 and 2, tax is qualified if buyer use local taxe
|
||||
{
|
||||
@ -3732,7 +3733,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
|
||||
{
|
||||
$conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY = 1;
|
||||
}
|
||||
|
||||
|
||||
// Search local taxes
|
||||
if (! empty($conf->global->MAIN_GET_LOCALTAXES_VALUES_FROM_THIRDPARTY))
|
||||
{
|
||||
@ -3789,7 +3790,7 @@ function get_localtax($vatrate, $local, $thirdparty_buyer="", $thirdparty_seller
|
||||
if ($local==1) return $obj->localtax1;
|
||||
elseif ($local==2) return $obj->localtax2;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -3849,7 +3850,7 @@ function get_localtax_by_third($local)
|
||||
|
||||
/**
|
||||
* Get vat rate and npr from id.
|
||||
* You can call getLocalTaxesFromRate after to get other fields
|
||||
* You can call getLocalTaxesFromRate after to get other fields
|
||||
*
|
||||
* @param int $vatrowid Line ID into vat rate table.
|
||||
* @return array array(localtax_type1(1-6 / 0 if not found), rate of localtax1, ...)
|
||||
@ -3903,7 +3904,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
$vatratecleaned = $reg[1];
|
||||
$vatratecode = $reg[2];
|
||||
}
|
||||
|
||||
|
||||
// Search local taxes
|
||||
$sql = "SELECT t.localtax1, t.localtax1_type, t.localtax2, t.localtax2_type, t.accountancy_code_sell, t.accountancy_code_buy";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_tva as t";
|
||||
@ -3976,7 +3977,7 @@ function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisi
|
||||
/**
|
||||
* Return vat rate of a product in a particular selling country or default country vat if product is unknown
|
||||
* Function called by get_default_tva
|
||||
*
|
||||
*
|
||||
* @param int $idprod Id of product or 0 if not a predefined product
|
||||
* @param Societe $thirdparty_seller Thirdparty with a ->country_code defined (FR, US, IT, ...)
|
||||
* @param int $idprodfournprice Id product_fournisseur_price (for "supplier" order/invoice)
|
||||
@ -4014,7 +4015,7 @@ function get_product_vat_for_country($idprod, $thirdparty_seller, $idprodfournpr
|
||||
}
|
||||
else
|
||||
{
|
||||
// TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet.
|
||||
// TODO Read default product vat according to countrycode and product. Vat for couple countrycode/product is a feature not implemeted yet.
|
||||
// May be usefull/required if hidden option SERVICE_ARE_ECOMMERCE_200238EC is on
|
||||
}
|
||||
}
|
||||
@ -4324,7 +4325,7 @@ function yn($yesno, $case=1, $color=0)
|
||||
/**
|
||||
* Return a path to have a directory according to object.
|
||||
* New usage: $conf->product->multidir_output[$object->entity].'/'.get_exdir(0, 0, 0, 1, $object, 'modulepart')
|
||||
* Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
|
||||
* Old usage: '015' with level 3->"0/1/5/", '015' with level 1->"5/", 'ABC-1' with level 3 ->"0/0/1/"
|
||||
*
|
||||
* @param string $num Id of object (deprecated, $object will be used in future)
|
||||
* @param int $level Level of subdirs to return (1, 2 or 3 levels). (deprecated, global option will be used in future)
|
||||
@ -4341,7 +4342,7 @@ function get_exdir($num, $level, $alpha, $withoutslash, $object, $modulepart)
|
||||
$path = '';
|
||||
|
||||
$arrayforoldpath=array('cheque','user','category','holiday','shipment','supplier_invoice','invoice_supplier','mailing');
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product';
|
||||
if (! empty($conf->global->PRODUCT_USE_OLD_PATH_FOR_PHOTO)) $arrayforoldpath[]='product';
|
||||
if (! empty($level) && in_array($modulepart, $arrayforoldpath))
|
||||
{
|
||||
// This part should be removed once all code is using "get_exdir" to forge path, with all parameters provided
|
||||
@ -4494,7 +4495,7 @@ function dolGetFirstLineOfText($text)
|
||||
{
|
||||
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
|
||||
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
|
||||
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -5400,7 +5401,7 @@ function picto_from_langcode($codelang)
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete or removed entries into a head array (used to build tabs).
|
||||
* Complete or removed entries into a head array (used to build tabs).
|
||||
* For example, with value added by external modules. Such values are declared into $conf->modules_parts['tab'].
|
||||
* Or by change using hook completeTabsHead
|
||||
*
|
||||
@ -5430,7 +5431,7 @@ function picto_from_langcode($codelang)
|
||||
function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add')
|
||||
{
|
||||
global $hookmanager;
|
||||
|
||||
|
||||
if (isset($conf->modules_parts['tabs'][$type]) && is_array($conf->modules_parts['tabs'][$type]))
|
||||
{
|
||||
foreach ($conf->modules_parts['tabs'][$type] as $value)
|
||||
@ -5496,7 +5497,7 @@ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode=
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// No need to make a return $head. Var is modified as a reference
|
||||
if (! empty($hookmanager))
|
||||
{
|
||||
@ -5534,11 +5535,11 @@ function printCommonFooter($zone='private')
|
||||
{
|
||||
print '<!-- Reposition management (does not work if a redirect is done after action of submission) -->'."\n";
|
||||
print '<script type="text/javascript" language="javascript">jQuery(document).ready(function() {'."\n";
|
||||
|
||||
|
||||
print '<!-- If page_y set, we set scollbar with it -->'."\n";
|
||||
print "page_y=getParameterByName('page_y', 0);";
|
||||
print "if (page_y > 0) $('html, body').scrollTop(page_y);\n";
|
||||
|
||||
|
||||
print '<!-- Set handler to add page_y param on some a href links -->'."\n";
|
||||
print 'jQuery(".reposition").click(function() {
|
||||
var page_y = $(document).scrollTop();
|
||||
@ -5546,7 +5547,7 @@ function printCommonFooter($zone='private')
|
||||
this.href=this.href+\'&page_y=\'+page_y;
|
||||
});'."\n";
|
||||
print '});'."\n";
|
||||
|
||||
|
||||
if (empty($conf->dol_use_jmobile))
|
||||
{
|
||||
print '<!-- Set handler to switch left menu page -->'."\n";
|
||||
@ -5555,10 +5556,10 @@ function printCommonFooter($zone='private')
|
||||
if ($conf->theme == 'md') print " $('.login_block').toggle();";
|
||||
print '});'."\n";
|
||||
}
|
||||
|
||||
|
||||
print '</script>'."\n";
|
||||
}
|
||||
|
||||
|
||||
// Google Analytics (need Google module)
|
||||
if (! empty($conf->google->enabled) && ! empty($conf->global->MAIN_GOOGLE_AN_ID))
|
||||
{
|
||||
@ -5717,9 +5718,9 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
{
|
||||
$value=preg_replace('/([<>=]+)\s+([0-9'.preg_quote($langs->trans("DecimalSeparator"),'/').'\-])/','\1\2',$value); // Clean string '< 10' into '<10' so we can the explode on space to get all tests to do
|
||||
}
|
||||
|
||||
|
||||
$value = preg_replace('/\s*\|\s*/','|', $value);
|
||||
|
||||
|
||||
$crits = explode(' ', $value);
|
||||
$res = '';
|
||||
if (! is_array($fields)) $fields = array($fields);
|
||||
@ -5774,15 +5775,15 @@ function natural_search($fields, $value, $mode=0, $nofirstand=0)
|
||||
$tmpcrit=trim($tmpcrit);
|
||||
$tmpcrit2=$tmpcrit;
|
||||
$tmpbefore='%'; $tmpafter='%';
|
||||
if (preg_match('/^[\^\$]/', $tmpcrit))
|
||||
{
|
||||
if (preg_match('/^[\^\$]/', $tmpcrit))
|
||||
{
|
||||
$tmpbefore='';
|
||||
$tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
|
||||
$tmpcrit2 = preg_replace('/^[\^\$]/', '', $tmpcrit2);
|
||||
}
|
||||
if (preg_match('/[\^\$]$/', $tmpcrit))
|
||||
{
|
||||
if (preg_match('/[\^\$]$/', $tmpcrit))
|
||||
{
|
||||
$tmpafter='';
|
||||
$tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
|
||||
$tmpcrit2 = preg_replace('/[\^\$]$/', '', $tmpcrit2);
|
||||
}
|
||||
$newres .= $tmpbefore;
|
||||
$newres .= $db->escape($tmpcrit2);
|
||||
@ -5848,7 +5849,7 @@ function getImageFileNameForSize($file, $extName, $extImgTarget='')
|
||||
function getAdvancedPreviewUrl($modulepart, $relativepath, $param='')
|
||||
{
|
||||
global $conf;
|
||||
|
||||
|
||||
if (empty($conf->use_javascript_ajax)) return '';
|
||||
|
||||
$mime_preview = array('bmp', 'jpeg', 'png', 'gif', 'tiff', 'pdf', 'plain', 'css');
|
||||
|
||||
@ -344,7 +344,7 @@ function restrictedArea($user, $features, $objectid=0, $tableandshare='', $featu
|
||||
* This function is also called by restrictedArea
|
||||
*
|
||||
* @param User $user User to check
|
||||
* @param array $featuresarray Features/modules to check. Example: ('user','service')
|
||||
* @param array $featuresarray Features/modules to check. Example: ('user','service','member','project','task',...)
|
||||
* @param int $objectid Object ID if we want to check a particular record (optional) is linked to a owned thirdparty (optional).
|
||||
* @param string $tableandshare 'TableName&SharedElement' with Tablename is table where object is stored. SharedElement is an optional key to define where to check entity for multicompany modume. Param not used if objectid is null (optional).
|
||||
* @param string $feature2 Feature to check, second level of permission (optional). Can be or check with 'level1|level2'.
|
||||
@ -368,11 +368,14 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
|
||||
// For backward compatibility
|
||||
if ($feature == 'member') $feature='adherent';
|
||||
if ($feature == 'project') $feature='projet';
|
||||
if ($feature == 'task') $feature='projet_task';
|
||||
|
||||
$check = array('adherent','banque','user','usergroup','produit','service','produit|service','categorie'); // Test on entity only (Objects with no link to company)
|
||||
$checksoc = array('societe'); // Test for societe object
|
||||
$checkother = array('contact'); // Test on entity and link to societe. Allowed if link is empty (Ex: contacts...).
|
||||
$checkproject = array('projet'); // Test for project object
|
||||
$checkproject = array('projet','project'); // Test for project object
|
||||
$checktask = array('projet_task');
|
||||
$nocheck = array('barcode','stock','fournisseur'); // No test
|
||||
$checkdefault = 'all other not already defined'; // Test on entity and link to third party. Not allowed if link is empty (Ex: invoice, orders...).
|
||||
|
||||
@ -452,7 +455,7 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
}
|
||||
else if (in_array($feature,$checkproject))
|
||||
{
|
||||
if (! empty($conf->projet->enabled) && ! $user->rights->projet->all->lire)
|
||||
if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$projectstatic=new Project($db);
|
||||
@ -468,6 +471,27 @@ function checkUserAccessToObject($user, $featuresarray, $objectid=0, $tableandsh
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else if (in_array($feature,$checktask))
|
||||
{
|
||||
if (! empty($conf->projet->enabled) && empty($user->rights->projet->all->lire))
|
||||
{
|
||||
$task = new Task($db);
|
||||
$task->fetch($objectid);
|
||||
|
||||
include_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
$projectstatic=new Project($db);
|
||||
$tmps=$projectstatic->getProjectsAuthorizedForUser($user,0,1,0);
|
||||
$tmparray=explode(',',$tmps);
|
||||
if (! in_array($task->fk_project,$tmparray)) return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "SELECT dbt.".$dbt_select;
|
||||
$sql.= " FROM ".MAIN_DB_PREFIX.$dbtablename." as dbt";
|
||||
$sql.= " WHERE dbt.".$dbt_select." = ".$objectid;
|
||||
$sql.= " AND dbt.entity IN (".getEntity($sharedelement, 1).")";
|
||||
}
|
||||
}
|
||||
else if (! in_array($feature,$nocheck)) // By default we check with link to third party
|
||||
{
|
||||
// If external user: Check permission for external users
|
||||
|
||||
@ -31,7 +31,7 @@
|
||||
*/
|
||||
|
||||
if (! defined('DOL_APPLICATION_TITLE')) define('DOL_APPLICATION_TITLE','Dolibarr');
|
||||
if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.3'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
|
||||
if (! defined('DOL_VERSION')) define('DOL_VERSION','5.0.4'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
|
||||
|
||||
if (! defined('EURO')) define('EURO',chr(128));
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ if (empty($reshook))
|
||||
$error++;
|
||||
setEventMessages($langs->trans("ErrorOppStatusRequiredIfAmount"), null, 'errors');
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$error=0;
|
||||
@ -308,8 +308,8 @@ if (empty($reshook))
|
||||
setEventMessages($langs->trans("FailedToCloseProject").':'.$object->error, $object->errors, 'errors');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if ($error)
|
||||
{
|
||||
$db->rollback();
|
||||
@ -322,7 +322,7 @@ if (empty($reshook))
|
||||
if (GETPOST('socid','int') > 0) $object->fetch_thirdparty(GETPOST('socid','int'));
|
||||
else unset($object->thirdparty);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Build doc
|
||||
@ -619,7 +619,7 @@ if ($action == 'create' && $user->rights->projet->creer)
|
||||
{
|
||||
print ' ';
|
||||
print '<input type="button" class="button" value="' . $langs->trans("Cancel") . '" onClick="javascript:history.go(-1)">';
|
||||
}
|
||||
}
|
||||
print '</div>';
|
||||
|
||||
print '</form>';
|
||||
@ -641,12 +641,12 @@ if ($action == 'create' && $user->rights->projet->creer)
|
||||
});
|
||||
</script>';
|
||||
}
|
||||
elseif ($object->id > 0)
|
||||
elseif ($object->id > 0)
|
||||
{
|
||||
/*
|
||||
* Show or edit
|
||||
*/
|
||||
|
||||
|
||||
$res=$object->fetch_optionals($object->id,$extralabels);
|
||||
|
||||
// To verify role of users
|
||||
@ -828,26 +828,26 @@ elseif ($object->id > 0)
|
||||
else
|
||||
{
|
||||
// Project card
|
||||
|
||||
|
||||
$linkback = '<a href="'.DOL_URL_ROOT.'/projet/list.php">'.$langs->trans("BackToList").'</a>';
|
||||
|
||||
|
||||
$morehtmlref='<div class="refidno">';
|
||||
// Title
|
||||
$morehtmlref.=$object->title;
|
||||
// Thirdparty
|
||||
if ($object->thirdparty->id > 0)
|
||||
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, 'ref', $linkback, 1, 'ref', 'ref', $morehtmlref);
|
||||
|
||||
|
||||
@ -881,18 +881,18 @@ elseif ($object->id > 0)
|
||||
if (strcmp($object->opp_amount,'')) print price($object->opp_amount,0,$langs,1,0,0,$conf->currency);
|
||||
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)
|
||||
if ($end)
|
||||
{
|
||||
print ' - '.$end;
|
||||
if ($object->hasDelay()) print img_warning($langs->trans('Late'));
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
|
||||
// Budget
|
||||
print '<tr><td>'.$langs->trans("Budget").'</td><td>';
|
||||
if (strcmp($object->budget_amount, '')) print price($object->budget_amount,0,$langs,1,0,0,$conf->currency);
|
||||
@ -901,16 +901,16 @@ elseif ($object->id > 0)
|
||||
// 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);
|
||||
@ -922,13 +922,13 @@ elseif ($object->id > 0)
|
||||
print $form->showCategories($object->id,'project',1);
|
||||
print "</td></tr>";
|
||||
}
|
||||
|
||||
|
||||
print '</table>';
|
||||
|
||||
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
print '</div>';
|
||||
|
||||
|
||||
print '<div class="clearboth"></div>';
|
||||
}
|
||||
|
||||
@ -947,9 +947,10 @@ elseif ($object->id > 0)
|
||||
// Change probability from status
|
||||
if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->PROJECT_USE_OPPORTUNITIES))
|
||||
{
|
||||
// Default value to close or not when we set opp to 'WON'.
|
||||
$defaultcheckedwhenoppclose=1;
|
||||
if (empty($conf->global->PROJECT_HIDE_TASKS)) $defaultcheckedwhenoppclose=0;
|
||||
|
||||
|
||||
print '<!-- Javascript to manage opportunity status change -->';
|
||||
print '<script type="text/javascript" language="javascript">
|
||||
jQuery(document).ready(function() {
|
||||
@ -962,13 +963,17 @@ elseif ($object->id > 0)
|
||||
var oldpercent = \''.dol_escape_js($object->opp_percent).'\';
|
||||
|
||||
console.log("We select "+elemcode);
|
||||
if (elemcode == \'LOST\') defaultcloseproject = 1;
|
||||
jQuery("#divtocloseproject").show();
|
||||
if (defaultcloseproject) jQuery("#inputcloseproject").prop("checked", true);
|
||||
|
||||
/* Define if checkbox to close is checked or not */
|
||||
closeproject = 0;
|
||||
if (elemcode == \'LOST\') closeproject = 1;
|
||||
if (elemcode == \'WON\') closeproject = defaultcloseproject;
|
||||
if (closeproject) jQuery("#inputcloseproject").prop("checked", true);
|
||||
else jQuery("#inputcloseproject").prop("checked", false);
|
||||
|
||||
/* Make close project visible or not */
|
||||
if (elemcode == \'WON\' || elemcode == \'LOST\')
|
||||
console.log("closeproject="+closeproject);
|
||||
|
||||
/* Make the close project checkbox visible or not */
|
||||
if (elemcode == \'WON\' || elemcode == \'LOST\')
|
||||
{
|
||||
jQuery("#divtocloseproject").show();
|
||||
}
|
||||
@ -976,7 +981,7 @@ elseif ($object->id > 0)
|
||||
{
|
||||
jQuery("#divtocloseproject").hide();
|
||||
}
|
||||
|
||||
|
||||
/* Change percent of default percent of new status is higher */
|
||||
if (parseFloat(jQuery("#opp_percent").val()) != parseFloat(defaultpercent))
|
||||
{
|
||||
@ -1003,7 +1008,7 @@ elseif ($object->id > 0)
|
||||
{
|
||||
if ($action != "edit" )
|
||||
{
|
||||
|
||||
|
||||
// Create event
|
||||
if ($conf->agenda->enabled && ! empty($conf->global->MAIN_ADD_EVENT_ON_ELEMENT_CARD)) // Add hidden condition because this is not a
|
||||
// "workflow" action so should appears somewhere else on
|
||||
|
||||
@ -20,7 +20,7 @@
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/project.class.php';
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
|
||||
|
||||
/**
|
||||
* API class for projects
|
||||
*
|
||||
@ -83,8 +83,8 @@ class Projects extends DolibarrApi
|
||||
return $this->_cleanObjectDatas($this->project);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* List projects
|
||||
*
|
||||
@ -102,7 +102,7 @@ class Projects extends DolibarrApi
|
||||
global $db, $conf;
|
||||
|
||||
$obj_ret = array();
|
||||
|
||||
|
||||
// case of external user, $thirdparty_ids param is ignored and replaced by user's socid
|
||||
$socids = DolibarrApiAccess::$user->societe_id ? DolibarrApiAccess::$user->societe_id : $thirdparty_ids;
|
||||
|
||||
@ -126,7 +126,7 @@ class Projects extends DolibarrApi
|
||||
$sql .= " AND sc.fk_user = ".$search_sale;
|
||||
}
|
||||
// Add sql filters
|
||||
if ($sqlfilters)
|
||||
if ($sqlfilters)
|
||||
{
|
||||
if (! DolibarrApi::_checkFilters($sqlfilters))
|
||||
{
|
||||
@ -135,7 +135,7 @@ class Projects extends DolibarrApi
|
||||
$regexstring='\(([^:\'\(\)]+:[^:\'\(\)]+:[^:\(\)]+)\)';
|
||||
$sql.=" AND (".preg_replace_callback('/'.$regexstring.'/', 'DolibarrApi::_forge_criteria_callback', $sqlfilters).")";
|
||||
}
|
||||
|
||||
|
||||
$sql.= $db->order($sortfield, $sortorder);
|
||||
if ($limit) {
|
||||
if ($page < 0)
|
||||
@ -227,7 +227,7 @@ class Projects extends DolibarrApi
|
||||
}
|
||||
$this->project->getLinesArray(DolibarrApiAccess::$user);
|
||||
$result = array();
|
||||
foreach ($this->project->lines as $line) // $line is a task
|
||||
foreach ($this->project->lines as $line) // $line is a task
|
||||
{
|
||||
if ($includetimespent == 1)
|
||||
{
|
||||
@ -243,7 +243,7 @@ class Projects extends DolibarrApi
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Get roles a user is assigned to a project with
|
||||
*
|
||||
@ -256,20 +256,20 @@ class Projects extends DolibarrApi
|
||||
*/
|
||||
function getRoles($id, $userid=0) {
|
||||
global $db;
|
||||
|
||||
|
||||
if(! DolibarrApiAccess::$user->rights->projet->lire) {
|
||||
throw new RestException(401);
|
||||
}
|
||||
|
||||
|
||||
$result = $this->project->fetch($id);
|
||||
if( ! $result ) {
|
||||
throw new RestException(404, 'Project not found');
|
||||
}
|
||||
|
||||
|
||||
if( ! DolibarrApi::_checkAccessToResource('project',$this->project->id)) {
|
||||
throw new RestException(401, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
|
||||
}
|
||||
|
||||
|
||||
require_once DOL_DOCUMENT_ROOT.'/projet/class/task.class.php';
|
||||
$taskstatic=new Task($this->db);
|
||||
$userp = DolibarrApiAccess::$user;
|
||||
@ -285,8 +285,8 @@ class Projects extends DolibarrApi
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Add a task to given project
|
||||
*
|
||||
@ -347,7 +347,7 @@ class Projects extends DolibarrApi
|
||||
return false;
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Update a task to given project
|
||||
*
|
||||
@ -405,9 +405,9 @@ class Projects extends DolibarrApi
|
||||
}
|
||||
return false;
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Update project general fields (won't touch lines of project)
|
||||
*
|
||||
@ -482,7 +482,7 @@ class Projects extends DolibarrApi
|
||||
* Validate a project.
|
||||
* You can test this API with the following input message
|
||||
* { "notrigger": 0 }
|
||||
*
|
||||
*
|
||||
* @param int $id Project ID
|
||||
* @param int $notrigger 1=Does not execute triggers, 0= execute triggers
|
||||
*
|
||||
@ -526,7 +526,7 @@ class Projects extends DolibarrApi
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Clean sensible object datas
|
||||
*
|
||||
@ -534,9 +534,12 @@ class Projects extends DolibarrApi
|
||||
* @return array Array of cleaned object properties
|
||||
*/
|
||||
function _cleanObjectDatas($object) {
|
||||
|
||||
|
||||
$object = parent::_cleanObjectDatas($object);
|
||||
|
||||
|
||||
unset($object->titre);
|
||||
unset($object->datec);
|
||||
unset($object->datem);
|
||||
unset($object->barcode_type);
|
||||
unset($object->barcode_type_code);
|
||||
unset($object->barcode_type_label);
|
||||
@ -558,21 +561,21 @@ class Projects extends DolibarrApi
|
||||
unset($object->country);
|
||||
unset($object->country_id);
|
||||
unset($object->country_code);
|
||||
|
||||
|
||||
unset($object->weekWorkLoad);
|
||||
unset($object->weekWorkLoad);
|
||||
|
||||
|
||||
//unset($object->lines); // for task we use timespent_lines, but for project we use lines
|
||||
|
||||
|
||||
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
|
||||
*
|
||||
@ -591,8 +594,8 @@ class Projects extends DolibarrApi
|
||||
}
|
||||
return $object;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
// TODO
|
||||
// getSummaryOfTimeSpent
|
||||
}
|
||||
|
||||
@ -179,32 +179,32 @@ class DateLibTest extends PHPUnit_Framework_TestCase
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
|
||||
// With same hours - Tuesday/Wednesday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013);
|
||||
|
||||
|
||||
$result=num_public_holiday($date1,$date2,'FR',1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for FR'); // 1 closed days
|
||||
|
||||
|
||||
$result=num_public_holiday($date1,$date2,'XX',1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(0,$result,'NumPublicHoliday for Tuesday/Wednesday jan 2013 for XX'); // no closed days (country unknown)
|
||||
|
||||
|
||||
// With same hours - Friday/Sunday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013);
|
||||
|
||||
|
||||
$result=num_public_holiday($date1,$date2,'FR',1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2,$result,'NumPublicHoliday for FR'); // 1 opened day, 2 closed days
|
||||
|
||||
$this->assertEquals(2,$result,'NumPublicHoliday for FR'); // 1 opened day, 2 closed days
|
||||
|
||||
$result=num_public_holiday($date1,$date2,'XX',1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2,$result,'NumPublicHoliday for XX'); // 1 opened day, 2 closed days (even if country unknown)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testNumOpenDay
|
||||
*
|
||||
@ -217,32 +217,32 @@ class DateLibTest extends PHPUnit_Framework_TestCase
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
|
||||
// With same hours - Tuesday/Wednesday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 1, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 2, 2013);
|
||||
|
||||
|
||||
$result=num_open_day($date1,$date2,0,1,0,'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for FR'); // 1 opened days
|
||||
|
||||
|
||||
$result=num_open_day($date1,$date2,0,1,0,'XX');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(2,$result,'NumOpenDay Tuesday/Wednesday jan 2013 for XX'); // 2 opened days (country unknown)
|
||||
|
||||
|
||||
// With same hours - Friday/Sunday jan 2013
|
||||
$date1=dol_mktime(0, 0, 0, 1, 4, 2013);
|
||||
$date2=dol_mktime(0, 0, 0, 1, 6, 2013);
|
||||
|
||||
|
||||
$result=num_open_day($date1,$date2,0,1,0,'FR');
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1,$result,'NumOpenDay for FR'); // 1 opened day, 2 closed
|
||||
|
||||
|
||||
$result=num_open_day($date1,$date2,'XX',1);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals(1,$result,'NumOpenDay for XX'); // 1 opened day, 2 closes (even if country unknown)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testConvertTime2Seconds
|
||||
*
|
||||
@ -335,6 +335,11 @@ class DateLibTest extends PHPUnit_Framework_TestCase
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('02/01/1970 00:00',$result);
|
||||
|
||||
// Check %a and %b format for fr_FR
|
||||
$result=dol_print_date(0,'%a %b %B',true,$outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('Jeu Jan. Janvier',$result);
|
||||
|
||||
// Check day format for en_US
|
||||
$outputlangs=new Translate('',$conf);
|
||||
$outputlangs->setDefaultLang('en_US');
|
||||
@ -345,9 +350,9 @@ class DateLibTest extends PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('01/02/1970',$result);
|
||||
|
||||
// Check %a and %b format for en_US
|
||||
$result=dol_print_date(0,'%a %b',true,$outputlangs);
|
||||
$result=dol_print_date(0,'%a %b %B',true,$outputlangs);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('Thu Jan',$result);
|
||||
$this->assertEquals('Thu Jan January',$result);
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user