This commit is contained in:
Maxime Kohlhaas 2017-07-09 10:13:02 +02:00
commit ba283377b9
21 changed files with 701 additions and 617 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1360,10 +1360,10 @@ class Commande extends CommonOrder
$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->localtax1_tx=$localtaxes_type[1];
$this->line->localtax2_tx=$localtaxes_type[3];
$this->line->localtax1_type=$localtaxes_type[0];
$this->line->localtax2_type=$localtaxes_type[2];
$this->line->fk_product=$fk_product;
$this->line->product_type=$product_type;
$this->line->fk_remise_except=$fk_remise_except;

View File

@ -206,7 +206,7 @@ if (GETPOST("button_removefilter_x") || GETPOST("button_removefilter") || GETPOS
$search_state="";
$search_type='';
$search_country='';
$search_type_thirdparty='';
$search_type_thirdparty='';
$day='';
$year='';
$month='';
@ -229,7 +229,7 @@ if (empty($reshook))
include DOL_DOCUMENT_ROOT.'/core/actions_massactions.inc.php';
}
/*
* View
@ -255,7 +255,7 @@ $sql.= " typent.code as typent_code,";
$sql.= " state.code_departement as state_code, state.nom as state_name";
// We need dynamount_payed to be able to sort on status (value is surely wrong because we can count several lines several times due to other left join or link with contacts. But what we need is just 0 or > 0)
// TODO Better solution to be able to sort on already payed or remain to pay is to store amount_payed in a denormalized field.
if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
if (! $sall) $sql.= ', SUM(pf.amount) as dynamount_payed';
// Add fields from extrafields
foreach ($extrafields->attribute_label as $key => $val) $sql.=($extrafields->attribute_type[$key] != 'separate' ? ",ef.".$key.' as options_'.$key : '');
// Add fields from hooks
@ -462,7 +462,7 @@ if ($resql)
'presend'=>$langs->trans("SendByMail"),
'builddoc'=>$langs->trans("PDFMerge")
);
if ($user->rights->facture->supprimer)
if ($user->rights->facture->supprimer)
{
//if (! empty($conf->global->STOCK_CALCULATE_ON_BILL) || empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED))
if (empty($conf->global->INVOICE_CAN_ALWAYS_BE_REMOVED))
@ -479,6 +479,7 @@ if ($resql)
$i = 0;
print '<form method="POST" name="searchFormList" action="'.$_SERVER["PHP_SELF"].'">'."\n";
if ($optioncss != '') print '<input type="hidden" name="optioncss" value="'.$optioncss.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="formfilteraction" id="formfilteraction" value="list">';
@ -492,8 +493,8 @@ if ($resql)
if ($massaction == 'presend')
{
$langs->load("mails");
if (! GETPOST('cancel'))
if (! GETPOST('cancel'))
{
$objecttmp=new Facture($db);
$listofselectedid=array();
@ -502,7 +503,7 @@ if ($resql)
foreach($arrayofselected as $toselectid)
{
$result=$objecttmp->fetch($toselectid);
if ($result > 0)
if ($result > 0)
{
$listofselectedid[$toselectid]=$toselectid;
$thirdpartyid=$objecttmp->fk_soc?$objecttmp->fk_soc:$objecttmp->socid;
@ -513,10 +514,10 @@ if ($resql)
}
print '<input type="hidden" name="massaction" value="confirm_presend">';
include_once DOL_DOCUMENT_ROOT.'/core/class/html.formmail.class.php';
$formmail = new FormMail($db);
dol_fiche_head(null, '', '');
$topicmail="SendBillRef";
@ -584,16 +585,16 @@ if ($resql)
//$formmail->param['returnurl']=$_SERVER["PHP_SELF"].'?id='.$object->id;
print $formmail->get_form();
dol_fiche_end();
}
if ($sall)
{
foreach($fieldstosearchall as $key => $val) $fieldstosearchall[$key]=$langs->trans($val);
print $langs->trans("FilterOnInto", $sall) . join(', ',$fieldstosearchall);
}
// If the user can view prospects other than his'
$moreforfilter='';
if ($user->rights->societe->client->voir || $socid)
@ -683,14 +684,14 @@ if ($resql)
// Filters lines
print '<tr class="liste_titre">';
// Ref
if (! empty($arrayfields['f.facnumber']['checked']))
if (! empty($arrayfields['f.facnumber']['checked']))
{
print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.$search_ref.'">';
print '</td>';
}
// Ref customer
if (! empty($arrayfields['f.ref_client']['checked']))
if (! empty($arrayfields['f.ref_client']['checked']))
{
print '<td class="liste_titre">';
print '<input class="flat" size="6" type="text" name="search_refcustomer" value="'.$search_refcustomer.'">';
@ -711,7 +712,7 @@ if ($resql)
print '</td>';
}
// Date invoice
if (! empty($arrayfields['f.date']['checked']))
if (! empty($arrayfields['f.date']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day" value="'.$day.'">';
@ -720,7 +721,7 @@ if ($resql)
print '</td>';
}
// Date due
if (! empty($arrayfields['f.date_lim_reglement']['checked']))
if (! empty($arrayfields['f.date_lim_reglement']['checked']))
{
print '<td class="liste_titre" align="center">';
if (! empty($conf->global->MAIN_LIST_FILTER_ON_DAY)) print '<input class="flat" type="text" size="1" maxlength="2" name="day_lim" value="'.$day_lim.'">';
@ -730,7 +731,7 @@ if ($resql)
print '</td>';
}
// Thirpdarty
if (! empty($arrayfields['s.nom']['checked']))
if (! empty($arrayfields['s.nom']['checked']))
{
print '<td class="liste_titre" align="left"><input class="flat" type="text" size="6" name="search_societe" value="'.$search_societe.'"></td>';
}
@ -760,7 +761,7 @@ if ($resql)
print '</td>';
}
// Payment mode
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
if (! empty($arrayfields['f.fk_mode_reglement']['checked']))
{
print '<td class="liste_titre" align="left">';
$form->select_types_paiements($search_paymentmode, 'search_paymentmode', '', 0, 0, 1, 10);
@ -875,19 +876,19 @@ if ($resql)
$totaldeposits = $facturestatic->getSumDepositsUsed();
$totalpay = $paiement + $totalcreditnotes + $totaldeposits;
$remaintopay = $obj->total_ttc - $totalpay;
print '<tr '.$bc[$var].'>';
if (! empty($arrayfields['f.facnumber']['checked']))
{
print '<td class="nowrap">';
print '<table class="nobordernopadding"><tr class="nocellnopadd">';
print '<td class="nobordernopadding nowrap">';
print $facturestatic->getNomUrl(1,'',200,0,'',0,1);
print $obj->increment;
print '</td>';
print '<td style="min-width: 20px" class="nobordernopadding nowrap">';
$filename=dol_sanitizeFileName($obj->facnumber);
$filedir=$conf->facture->dir_output . '/' . dol_sanitizeFileName($obj->facnumber);
@ -896,7 +897,7 @@ if ($resql)
print '</td>';
print '</tr>';
print '</table>';
print "</td>\n";
if (! $i) $totalarray['nbfield']++;
}
@ -1085,12 +1086,12 @@ if ($resql)
// Status
if (! empty($arrayfields['f.fk_statut']['checked']))
{
print '<td align="right" class="nowrap">';
print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type);
print "</td>";
if (! $i) $totalarray['nbfield']++;
print '<td align="right" class="nowrap">';
print $facturestatic->LibStatut($obj->paye,$obj->fk_statut,5,$paiement,$obj->type);
print "</td>";
if (! $i) $totalarray['nbfield']++;
}
// Action column
print '<td class="nowrap" align="center">';
if ($massactionbutton || $massaction) // If we are in select mode (massactionbutton defined) or if we have already selected and sent an action ($massaction) defined
@ -1101,7 +1102,7 @@ if ($resql)
}
print '</td>' ;
if (! $i) $totalarray['nbfield']++;
print "</tr>\n";
$i++;
@ -1128,21 +1129,21 @@ if ($resql)
else print '<td></td>';
}
print '</tr>';
}
}
$db->free($resql);
$parameters=array('arrayfields'=>$arrayfields, 'sql'=>$sql);
$reshook=$hookmanager->executeHooks('printFieldListFooter',$parameters); // Note that $action and $object may have been modified by hook
print $hookmanager->resPrint;
print "</table>\n";
print "</div>";
print "</form>\n";
if ($massaction == 'builddoc' || $action == 'remove_file' || $show_files)
{
/*
@ -1150,11 +1151,11 @@ if ($resql)
*/
$urlsource=$_SERVER['PHP_SELF'].'?sortfield='.$sortfield.'&sortorder='.$sortorder;
$urlsource.=str_replace('&amp;','&',$param);
$filedir=$diroutputmassaction;
$genallowed=$user->rights->facture->lire;
$delallowed=$user->rights->facture->lire;
print $formfile->showdocuments('massfilesarea_invoices','',$filedir,$urlsource,0,$delallowed,'',1,1,0,48,1,$param,$title,'');
}
else

View File

@ -46,7 +46,7 @@ class Cpaiement
/**
*/
public $code;
public $libelle;
public $type;
@ -56,7 +56,7 @@ class Cpaiement
/**
*/
/**
* Constructor
@ -83,7 +83,7 @@ class Cpaiement
$error = 0;
// Clean parameters
if (isset($this->code)) {
$this->code = trim($this->code);
}
@ -103,14 +103,14 @@ class Cpaiement
$this->module = trim($this->module);
}
// Check parameters
// Put here code to add control on parameters values
// Insert request
$sql = 'INSERT INTO ' . MAIN_DB_PREFIX . $this->table_element . '(';
$sql.= 'id,';
$sql.= 'code,';
$sql.= 'libelle,';
@ -119,9 +119,9 @@ class Cpaiement
$sql.= 'accountancy_code,';
$sql.= 'module';
$sql .= ') VALUES (';
$sql .= ' '.(! isset($this->id)?'NULL':$this->id).',';
$sql .= ' '.(! isset($this->code)?'NULL':"'".$this->db->escape($this->code)."'").',';
$sql .= ' '.(! isset($this->libelle)?'NULL':"'".$this->db->escape($this->libelle)."'").',';
@ -130,7 +130,7 @@ class Cpaiement
$sql .= ' '.(! isset($this->accountancy_code)?'NULL':"'".$this->db->escape($this->accountancy_code)."'").',';
$sql .= ' '.(! isset($this->module)?'NULL':"'".$this->db->escape($this->module)."'");
$sql .= ')';
$this->db->begin();
@ -202,7 +202,7 @@ class Cpaiement
$obj = $this->db->fetch_object($resql);
$this->id = $obj->id;
$this->code = $obj->code;
$this->libelle = $obj->libelle;
$this->type = $obj->type;
@ -210,7 +210,7 @@ class Cpaiement
$this->accountancy_code = $obj->accountancy_code;
$this->module = $obj->module;
}
$this->db->free($resql);
@ -252,7 +252,7 @@ class Cpaiement
$sql .= " t.accountancy_code,";
$sql .= " t.module";
$sql .= ' FROM ' . MAIN_DB_PREFIX . $this->table_element. ' as t';
// Manage filter
@ -265,7 +265,7 @@ class Cpaiement
if (count($sqlwhere) > 0) {
$sql .= ' WHERE ' . implode(' '.$filtermode.' ', $sqlwhere);
}
if (!empty($sortfield)) {
$sql .= $this->db->order($sortfield,$sortorder);
}
@ -279,10 +279,10 @@ class Cpaiement
$num = $this->db->num_rows($resql);
while ($obj = $this->db->fetch_object($resql)) {
$line = new CpaiementLine();
$line = new Cpaiement();
$line->id = $obj->id;
$line->code = $obj->code;
$line->libelle = $obj->libelle;
$line->type = $obj->type;
@ -290,7 +290,7 @@ class Cpaiement
$line->accountancy_code = $obj->accountancy_code;
$line->module = $obj->module;
$this->lines[$line->id] = $line;
}
@ -320,7 +320,7 @@ class Cpaiement
dol_syslog(__METHOD__, LOG_DEBUG);
// Clean parameters
if (isset($this->code)) {
$this->code = trim($this->code);
}
@ -340,7 +340,7 @@ class Cpaiement
$this->module = trim($this->module);
}
// Check parameters
// Put here code to add a control on parameters values
@ -438,8 +438,8 @@ class Cpaiement
return 1;
}
}
/**
* Initialise object with example values
* Id must be 0 if object instance is a specimen
@ -449,7 +449,7 @@ class Cpaiement
public function initAsSpecimen()
{
$this->id = 0;
$this->code = '';
$this->libelle = '';
$this->type = '';
@ -457,7 +457,7 @@ class Cpaiement
$this->accountancy_code = '';
$this->module = '';
}
}

View File

@ -196,7 +196,6 @@ if ($action == 'update' && ! $_POST["cancel"] && $user->rights->tax->charges->cr
{
$result=$object->fetch($id);
$object->lib=GETPOST('label');
$object->date_ech=$dateech;
$object->periode=$dateperiod;
$object->amount=price2num($amount);

View File

@ -228,7 +228,7 @@ class Contrat extends CommonObject
*/
function active_line($user, $line_id, $date, $date_end='', $comment='')
{
$this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment);
return $this->lines[$this->lines_id_index_mapper[$line_id]]->active_line($user, $date, $date_end, $comment);
}
@ -243,7 +243,7 @@ class Contrat extends CommonObject
*/
function close_line($user, $line_id, $date_end, $comment='')
{
$this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment);
return $this->lines[$this->lines_id_index_mapper[$line_id]]->close_line($user, $date_end, $comment);
}

View File

@ -599,48 +599,64 @@ abstract class CommonObject
}
$datecreate = dol_now();
$this->db->begin();
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= "'".$this->db->idate($datecreate)."'";
$sql.= ", 4, ". $id_type_contact;
$sql.= ")";
$resql=$this->db->query($sql);
if ($resql)
{
if (! $notrigger)
{
$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
if ($result < 0)
// Socpeople must have already been added by some a trigger, then we have to check it to avoid DB_ERROR_RECORD_ALREADY_EXISTS error
$TListeContacts=$this->liste_contact(-1, $source);
$already_added=false;
if(!empty($TListeContacts)) {
foreach($TListeContacts as $array_contact) {
if($array_contact['status'] == 4 && $array_contact['id'] == $fk_socpeople && $array_contact['fk_c_type_contact'] == $id_type_contact) {
$already_added=true;
break;
}
}
}
if(!$already_added) {
$this->db->begin();
// Insertion dans la base
$sql = "INSERT INTO ".MAIN_DB_PREFIX."element_contact";
$sql.= " (element_id, fk_socpeople, datecreate, statut, fk_c_type_contact) ";
$sql.= " VALUES (".$this->id.", ".$fk_socpeople." , " ;
$sql.= "'".$this->db->idate($datecreate)."'";
$sql.= ", 4, ". $id_type_contact;
$sql.= ")";
$resql=$this->db->query($sql);
if ($resql)
{
if (! $notrigger)
{
$result=$this->call_trigger(strtoupper($this->element).'_ADD_CONTACT', $user);
if ($result < 0)
{
$this->db->rollback();
return -1;
}
}
$this->db->commit();
return 1;
}
else
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$this->db->errno();
$this->db->rollback();
echo 'err rollback';
return -2;
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -1;
}
}
$this->db->commit();
return 1;
}
else
{
if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS')
{
$this->error=$this->db->errno();
$this->db->rollback();
return -2;
}
else
{
$this->error=$this->db->error();
$this->db->rollback();
return -1;
}
}
}
} else return 0;
}
/**

View File

@ -3892,7 +3892,7 @@ function getTaxesFromId($vatrowid)
* @param Societe $buyer Company object
* @param Societe $seller Company object
* @param int $firstparamisid 1 if first param is id into table (use this if you can)
* @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type1, rate localtax2, accountancycodecust, accountancycodesupp)
* @return array array(localtax_type1(1-6/0 if not found), rate localtax1, localtax_type2, rate localtax2, accountancycodecust, accountancycodesupp)
*/
function getLocalTaxesFromRate($vatrate, $local, $buyer, $seller, $firstparamisid=0)
{

View File

@ -28,7 +28,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier
/**
* Class to manage customer payment numbering rules Ant
*/
class mod_supplier_payment_brodator extends ModeleNumRefPayments
class mod_supplier_payment_brodator extends ModeleNumRefSupplierPayments
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $error = '';

View File

@ -27,7 +27,7 @@ require_once DOL_DOCUMENT_ROOT .'/core/modules/supplier_payment/modules_supplier
/**
* Class to manage customer payment numbering rules Cicada
*/
class mod_supplier_payment_bronan extends ModeleNumRefPayments
class mod_supplier_payment_bronan extends ModeleNumRefSupplierPayments
{
var $version='dolibarr'; // 'development', 'experimental', 'dolibarr'
var $prefix='SPAY';

View File

@ -17,11 +17,11 @@
*/
/**
* \class ModeleNumRefPayments
* \class ModeleNumRefSupplierPayments
* \brief Payment numbering references mother class
*/
abstract class ModeleNumRefPayments
abstract class ModeleNumRefSupplierPayments
{
var $error='';

File diff suppressed because it is too large Load Diff

View File

@ -37,9 +37,9 @@ class ExpenseReport extends CommonObject
var $picto = 'trip';
var $lignes=array();
public $date_debut;
public $date_fin;
var $fk_user_validator;
@ -65,7 +65,7 @@ class ExpenseReport extends CommonObject
// Update
var $date_modif;
var $fk_user_modif;
// Refus
var $date_refuse;
var $detail_refuse;
@ -128,7 +128,7 @@ class ExpenseReport extends CommonObject
$fuserid = $this->fk_user_author; // Note fk_user_author is not the 'author' but the guy the expense report is for.
if (empty($fuserid)) $fuserid = $user->id;
$this->db->begin();
$sql = "INSERT INTO ".MAIN_DB_PREFIX.$this->table_element." (";
@ -235,35 +235,35 @@ class ExpenseReport extends CommonObject
function createFromClone($socid=0)
{
global $user,$hookmanager;
$error=0;
$this->context['createfromclone'] = 'createfromclone';
$this->db->begin();
// get extrafields so they will be clone
foreach($this->lines as $line)
//$line->fetch_optionals($line->rowid);
// Load source object
$objFrom = clone $this;
$this->id=0;
$this->ref = '';
$this->statut=0;
// Clear fields
$this->fk_user_author = $user->id; // Note fk_user_author is not the 'author' but the guy the expense report is for.
$this->fk_user_valid = '';
$this->date_create = '';
$this->date_creation = '';
$this->date_validation = '';
// Create clone
$result=$this->create($user);
if ($result < 0) $error++;
if (! $error)
{
// Hook of thirdparty module
@ -274,15 +274,15 @@ class ExpenseReport extends CommonObject
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++;
}
// Call trigger
$result=$this->call_trigger('EXPENSEREPORT_CLONE',$user);
if ($result < 0) $error++;
// End call triggers
}
unset($this->context['createfromclone']);
// End
if (! $error)
{
@ -295,8 +295,8 @@ class ExpenseReport extends CommonObject
return -1;
}
}
/**
* update
*
@ -399,7 +399,7 @@ class ExpenseReport extends CommonObject
$this->fk_user_refuse = $obj->fk_user_refuse;
$this->fk_user_cancel = $obj->fk_user_cancel;
$this->fk_user_approve = $obj->fk_user_approve;
$user_author = new User($this->db);
if ($this->fk_user_author > 0) $user_author->fetch($this->fk_user_author);
@ -588,7 +588,7 @@ class ExpenseReport extends CommonObject
$auser->fetch($obj->fk_user_approve);
$this->user_approve = $auser;
}
}
$this->db->free($resql);
}
@ -1000,7 +1000,7 @@ class ExpenseReport extends CommonObject
$sql.= ", ref_number_int = ".$ref_number_int;
}
$sql.= ' WHERE rowid = '.$this->id;
$resql=$this->db->query($sql);
if ($resql)
{
@ -1215,7 +1215,7 @@ class ExpenseReport extends CommonObject
$sql = 'SELECT MAX(de.ref_number_int) as max';
$sql.= ' FROM '.MAIN_DB_PREFIX.$this->table_element.' de';
$result = $this->db->query($sql);
if($this->db->num_rows($result) > 0):
@ -1359,7 +1359,7 @@ class ExpenseReport extends CommonObject
* @param int $rowid Line to edit
* @param int $type_fees_id Type payment
* @param int $projet_id Project id
* @param double $vatrate Vat rate
* @param double $vatrate Vat rate. Can be '8.5* (8.5NPROM...)'
* @param string $comments Description
* @param real $qty Qty
* @param double $value_unit Value init
@ -1369,14 +1369,34 @@ class ExpenseReport extends CommonObject
*/
function updateline($rowid, $type_fees_id, $projet_id, $vatrate, $comments, $qty, $value_unit, $date, $expensereport_id)
{
global $user;
global $user, $mysoc;
if ($this->fk_statut==0 || $this->fk_statut==99)
{
$this->db->begin();
$type = 0; // TODO What if type is service ?
// We don't know seller and buyer for expense reports
$seller = $mysoc;
$buyer = new Societe($this->db);
$localtaxes_type=getLocalTaxesFromRate($vatrate,0,$buyer,$seller);
// Clean vat code
$vat_src_code='';
if (preg_match('/\((.*)\)/', $vatrate, $reg))
{
$vat_src_code = $reg[1];
$vatrate = preg_replace('/\s*\(.*\)/', '', $vatrate); // Remove code into vatrate.
}
$vatrate = preg_replace('/\*/','',$vatrate);
$tmp = calcul_price_total($qty, $value_unit, 0, $vatrate, 0, 0, 0, 'TTC', 0, $type, $seller, $localtaxes_type);
// calcul de tous les totaux de la ligne
$total_ttc = price2num($qty*$value_unit, 'MT');
//$total_ttc = price2num($qty*$value_unit, 'MT');
$tx_tva = $vatrate / 100;
$tx_tva = $tx_tva + 1;
@ -1386,6 +1406,9 @@ class ExpenseReport extends CommonObject
// fin calculs
$ligne = new ExpenseReportLine($this->db);
$ligne->rowid = $rowid;
$ligne->comments = $comments;
$ligne->qty = $qty;
$ligne->value_unit = $value_unit;
@ -1395,11 +1418,21 @@ class ExpenseReport extends CommonObject
$ligne->fk_c_type_fees = $type_fees_id;
$ligne->fk_projet = $projet_id;
$ligne->total_ht = $total_ht;
$ligne->total_tva = $total_tva;
$ligne->total_ttc = $total_ttc;
$ligne->vatrate = price2num($vatrate);
$ligne->rowid = $rowid;
//$ligne->total_ht = $total_ht;
//$ligne->total_tva = $total_tva;
//$ligne->total_ttc = $total_ttc;
//$ligne->vatrate = price2num($vatrate);
$ligne->vat_src_code = $vat_src_code;
$ligne->vatrate = price2num($vatrate);
$ligne->total_ttc = $tmp[2];
$ligne->total_ht = $tmp[0];
$ligne->total_tva = $tmp[1];
$ligne->localtax1_tx = $localtaxes_type[1];
$ligne->localtax2_tx = $localtaxes_type[3];
$ligne->localtax1_type = $localtaxes_type[0];
$ligne->localtax2_type = $localtaxes_type[2];
// Select des infos sur le type fees
$sql = "SELECT c.code as code_type_fees, c.label as libelle_type_fees";
@ -1540,7 +1573,7 @@ class ExpenseReport extends CommonObject
$sql.= " FROM ".MAIN_DB_PREFIX."usergroup_user as ugu, ".MAIN_DB_PREFIX."usergroup_rights as ur, ".MAIN_DB_PREFIX."rights_def as rd";
$sql.= " WHERE ugu.fk_usergroup = ur.fk_usergroup AND ur.fk_id = rd.id and rd.module = 'expensereport' AND rd.perms = 'approve'"; // Permission 'Approve';
//print $sql;
dol_syslog(get_class($this)."::fetch_users_approver_expensereport sql=".$sql);
$result = $this->db->query($sql);
if($result)
@ -1679,7 +1712,7 @@ class ExpenseReport extends CommonObject
$now=dol_now();
$userchildids = $user->getAllChildIds(1);
$sql = "SELECT ex.rowid, ex.date_valid";
$sql.= " FROM ".MAIN_DB_PREFIX."expensereport as ex";
if ($option == 'toapprove') $sql.= " WHERE ex.fk_statut = 2";
@ -1711,7 +1744,7 @@ class ExpenseReport extends CommonObject
while ($obj=$this->db->fetch_object($resql))
{
$response->nbtodo++;
if ($option == 'toapprove')
{
if ($this->db->jdate($obj->date_valid) < ($now - $conf->expensereport->approve->warning_delay)) {
@ -1735,7 +1768,7 @@ class ExpenseReport extends CommonObject
return -1;
}
}
/**
* Return if an expense report is late or not
*
@ -1745,11 +1778,11 @@ class ExpenseReport extends CommonObject
public function hasDelay($option)
{
global $conf;
//Only valid members
if ($option == 'toapprove' && $this->status != 2) return false;
if ($option == 'topay' && $this->status != 5) return false;
$now = dol_now();
if ($option == 'toapprove')
{
@ -1757,7 +1790,7 @@ class ExpenseReport extends CommonObject
}
else
return ($this->datevalid?$this->datevalid:$this->date_valid) < ($now - $conf->expensereport->payment->warning_delay);
}
}
}

View File

@ -479,7 +479,7 @@ class PaymentExpenseReport extends CommonObject
$total=$this->total;
if ($mode == 'payment_expensereport') $amount=$total;
// Insert payment into llx_bank
$bank_line_id = $acc->addline(
$this->datepaid,
@ -516,25 +516,25 @@ class PaymentExpenseReport extends CommonObject
dol_print_error($this->db);
}
}
// Add link 'user' in bank_url between user and bank transaction
if (! $error)
{
foreach ($this->amounts as $key => $value) // We should have always same third party but we loop in case of.
foreach ($this->amounts as $key => $value) // We should have always same user but we loop in case of.
{
if ($mode == 'payment_expensereport')
{
$er = new ExpenseReport($this->db);
$er->fetch($key);
$er->fetch_user($er->fk_user_author);
$fuser = new User($this->db);
$fuser->fetch($key);
$result=$acc->add_url_line(
$bank_line_id,
$er->user->id,
$fuser->id,
DOL_URL_ROOT.'/user/card.php?id=',
$er->user->getFullName($langs),
$fuser->getFullName($langs),
'user'
);
if ($result <= 0)
if ($result <= 0)
{
$this->error=$this->db->lasterror();
dol_syslog(get_class($this).'::addPaymentToBank '.$this->error);

View File

@ -78,7 +78,7 @@ if ($action == 'add_payment')
setEventMessages($langs->trans("ErrorFieldRequired",$langs->transnoentities("AccountToDebit")), null, 'errors');
$error++;
}
if (! $error)
{
$paymentid = 0;
@ -176,7 +176,7 @@ if (GETPOST("action") == 'create')
print '<input type="hidden" name="id" value="'.$chid.'">';
print '<input type="hidden" name="chid" value="'.$chid.'">';
print '<input type="hidden" name="action" value="add_payment">';
dol_fiche_head();
print '<table cellspacing="0" class="border" width="100%" cellpadding="2">';
@ -225,7 +225,7 @@ if (GETPOST("action") == 'create')
$form->select_comptes(isset($_POST["accountid"])?$_POST["accountid"]:$expensereport->accountid, "accountid", 0, '',1); // Show open bank account list
print '</td></tr>';
}
// Number
print '<tr><td>'.$langs->trans('Numero');
print ' <em>('.$langs->trans("ChequeOrTransferNumber").')</em>';

View File

@ -878,7 +878,7 @@ if (empty($reshook))
}
// Actions to build doc
$upload_dir = $conf->commande->dir_output;
$upload_dir = $conf->fournisseur->commande->dir_output;
$permissioncreate = $user->rights->fournisseur->commande->creer;
include DOL_DOCUMENT_ROOT.'/core/actions_builddoc.inc.php';

View File

@ -3,8 +3,8 @@
* Copyright (C) 2012-2016 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2012-2016 Regis Houssin <regis.houssin@capnetworks.com>
* Copyright (C) 2013 Juanjo Menent <jmenent@2byte.es>
* Copyright (C) 2014 Ferran Marcet <fmarcet@2byte.es>
* Copyright (C) 2017 Alexandre Spangaro <aspangaro@zendsi.com>
* Copyright (C) 2014-2017 Ferran Marcet <fmarcet@2byte.es>
*
* 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
@ -41,7 +41,6 @@ require_once DOL_DOCUMENT_ROOT.'/holiday/common.inc.php';
$myparam = GETPOST("myparam");
$action=GETPOST('action', 'alpha');
$id=GETPOST('id', 'int');
$userid = GETPOST('userid')?GETPOST('userid'):$user->id;
// Protection if external user
if ($user->societe_id > 0) accessforbidden();
@ -61,7 +60,8 @@ if ($action == 'create')
$object = new Holiday($db);
// If no right to create a request
if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all)))
$fuserid = GETPOST('fuserid');
if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all)))
{
$error++;
setEventMessages($langs->trans('CantCreateCP'), null, 'errors');
@ -86,7 +86,6 @@ if ($action == 'create')
$valideur = GETPOST('valideur');
$description = trim(GETPOST('description'));
$userID = GETPOST('userID');
// If no type
if ($type <= 0)
@ -576,27 +575,27 @@ if ($action == 'confirm_draft' && GETPOST('confirm') == 'yes')
{
$object = new Holiday($db);
$object->fetch($id);
$oldstatus = $object->statut;
$object->statut = 1;
$result = $object->update($user);
if ($result < 0)
{
$error = $langs->trans('ErrorBackToDraft');
}
if (! $error)
{
$db->commit();
header('Location: '.$_SERVER["PHP_SELF"].'?id='.$object->id);
exit;
}
else
{
$db->rollback();
}
}
}
// Si Validation de la demande
@ -722,7 +721,7 @@ llxHeader('', $langs->trans('CPTitreMenu'));
if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create')
{
// Si l'utilisateur n'a pas le droit de faire une demande
if (($userid == $user->id && empty($user->rights->holiday->write)) || ($userid != $user->id && empty($user->rights->holiday->write_all)))
if (($fuserid == $user->id && empty($user->rights->holiday->write)) || ($fuserid != $user->id && empty($user->rights->holiday->write_all)))
{
$errors[]=$langs->trans('CantCreateCP');
}
@ -802,7 +801,6 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
// Formulaire de demande
print '<form method="POST" action="'.$_SERVER['PHP_SELF'].'" onsubmit="return valider()" name="demandeCP">'."\n";
print '<input type="hidden" name="action" value="create" />'."\n";
print '<input type="hidden" name="userID" value="'.$userid.'" />'."\n";
dol_fiche_head();
@ -833,10 +831,10 @@ if (empty($id) || $action == 'add' || $action == 'request' || $action == 'create
print '<td>';
if (empty($user->rights->holiday->write_all))
{
print $form->select_dolusers($userid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '<input type="hidden" name="userid" value="'.$userid.'">';
print $form->select_dolusers($fuserid, 'useridbis', 0, '', 1, '', '', 0, 0, 0, '', 0, '', 'maxwidth300');
print '<input type="hidden" name="fuserid" value="'.($fuserid?$fuserid:$user->id).'">';
}
else print $form->select_dolusers(GETPOST('userid')?GETPOST('userid'):$user->id,'userid',0,'',0);
else print $form->select_dolusers(GETPOST('fuserid')?GETPOST('fuserid'):$user->id,'fuserid',0,'',0);
print '</td>';
print '</tr>';
@ -1023,7 +1021,7 @@ else
{
print $form->formconfirm($_SERVER["PHP_SELF"]."?id=".$object->id,$langs->trans("TitleSetToDraft"),$langs->trans("ConfirmSetToDraft"),"confirm_draft", '', 1, 1);
}
$head=holiday_prepare_head($object);
@ -1038,14 +1036,14 @@ else
dol_fiche_head($head,'card',$langs->trans("CPTitreMenu"),0,'holiday');
$linkback='<a href="'.DOL_URL_ROOT.'/holiday/list.php">'.$langs->trans("BackToList").'</a>';
dol_banner_tab($object, 'id', $linkback, 1, 'rowid', 'ref');
print '<div class="fichecenter">';
print '<div class="fichehalfleft">';
print '<div class="underbanner clearboth"></div>';
print '<table class="border centpercent">';
print '<tbody>';
@ -1147,9 +1145,9 @@ else
print '</div>';
print '<div class="fichehalfright">';
print '<div class="ficheaddleft">';
print '<div class="underbanner clearboth"></div>';
// Info workflow
print '<table class="border centpercent">'."\n";
print '<tbody>';
@ -1206,12 +1204,12 @@ else
print '</div>';
print '</div>';
print '</div>';
print '<div class="clearboth"></div>';
dol_fiche_end();
if ($action == 'edit' && $object->statut == 1)
{
print '<div align="center">';
@ -1267,7 +1265,7 @@ else
{
print '<a href="'.$_SERVER["PHP_SELF"].'?id='.$object->id.'&action=backtodraft" class="butAction">'.$langs->trans("SetToDraft").'</a>';
}
print '</div>';
}

View File

@ -70,7 +70,6 @@ $type = GETPOST('type','int');
// List of fields to search into when doing a "search in all"
$fieldstosearchall = array(
'cp.rowid'=>'Ref',
'cp.description'=>'Description',
'uu.lastname'=>'EmployeeLastname',
'uu.firstname'=>'EmployeeFirstname'
@ -124,7 +123,7 @@ $order = $db->order($sortfield,$sortorder).$db->plimit($limit + 1, $offset);
// WHERE
if(!empty($search_ref))
{
$filter.= " AND cp.rowid LIKE '%".$db->escape($search_ref)."%'\n";
$filter.= " AND cp.rowid = ".$db->escape($search_ref);
}
// DATE START

View File

@ -63,7 +63,7 @@ ALTER TABLE llx_bookmark ADD COLUMN entity integer DEFAULT 1 NOT NULL;
ALTER TABLE llx_bookmark MODIFY COLUMN url varchar(255) NOT NULL;
ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00';
-- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-01 00:00:00';
-- Clean corrupted values for tms
-- VMYSQL4.1 SET sql_mode = 'ALLOW_INVALID_DATES';
@ -74,7 +74,7 @@ ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT '2001-01-
-- VMYSQL4.3 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN date_fin DATETIME NULL DEFAULT NULL;
-- VPGSQL8.2 ALTER TABLE llx_opensurvey_sondage ALTER COLUMN date_fin DROP NOT NULL;
ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP;
-- VMYSQL4.1 ALTER TABLE llx_opensurvey_sondage MODIFY COLUMN tms timestamp DEFAULT CURRENT_TIMESTAMP;
ALTER TABLE llx_opensurvey_sondage ADD COLUMN entity integer DEFAULT 1 NOT NULL;
@ -204,9 +204,14 @@ CREATE TABLE llx_payment_salary (
fk_user_modif integer
)ENGINE=innodb;
DELETE FROM llx_product_batch where fk_product_stock NOT IN (SELECT rowid from llx_product_stock);
ALTER TABLE llx_product_batch ADD INDEX idx_fk_product_stock (fk_product_stock);
ALTER TABLE llx_product_batch ADD CONSTRAINT fk_product_batch_fk_product_stock FOREIGN KEY (fk_product_stock) REFERENCES llx_product_stock (rowid);
DELETE FROM llx_expeditiondet_batch where fk_expeditiondet NOT IN (SELECT rowid from llx_expeditiondet);
ALTER TABLE llx_expeditiondet_batch ADD INDEX idx_fk_expeditiondet (fk_expeditiondet);
ALTER TABLE llx_expeditiondet_batch ADD CONSTRAINT fk_expeditiondet_batch_fk_expeditiondet FOREIGN KEY (fk_expeditiondet) REFERENCES llx_expeditiondet(rowid);

View File

@ -306,6 +306,14 @@ DELETE FROM llx_c_shipment_mode where code IN (select code from tmp_c_shipment_m
drop table tmp_c_shipment_mode;
-- Restore id of user on link for payment of expense report
drop table tmp_bank_url_expense_user;
create table tmp_bank_url_expense_user (select e.fk_user_author, bu2.fk_bank from llx_expensereport as e, llx_bank_url as bu2 where bu2.url_id = e.rowid and bu2.type = 'payment_expensereport');
update llx_bank_url as bu set url_id = (select e.fk_user_author from tmp_bank_url_expense_user as e where e.fk_bank = bu.fk_bank) where bu.url_id = 0 and bu.type ='user';
drop table tmp_bank_url_expense_user;
-- Clean product prices
--delete from llx_product_price where date_price between '2017-04-20 06:51:00' and '2017-04-20 06:51:05';
-- Set product prices into llx_product with last price into llx_product_prices

View File

@ -144,7 +144,7 @@ if ($id > 0 || ! empty($ref))
elseif ($user->rights->facture->lire)
{
$sql = "SELECT DISTINCT s.nom as name, s.rowid as socid, s.code_client,";
$sql.= " f.facnumber, f.datef, f.paye, f.fk_statut as statut, f.rowid as facid,";
$sql.= " f.facnumber, f.datef, f.paye, f.type, f.fk_statut as statut, f.rowid as facid,";
$sql.= " d.rowid, d.total_ht as total_ht, d.qty"; // We must keep the d.rowid here to not loose record because of the distinct used to ignore duplicate line when link on societe_commerciaux is used
if (!$user->rights->societe->client->voir && !$socid) $sql.= ", sc.fk_soc, sc.fk_user ";
$sql.= " FROM ".MAIN_DB_PREFIX."societe as s";
@ -236,23 +236,24 @@ if ($id > 0 || ! empty($ref))
$var=True;
while ($i < min($num,$conf->liste_limit))
{
$objp = $db->fetch_object($result);
$objp = $db->fetch_object($result);
$invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->facnumber;
$societestatic->fetch($objp->socid);
$paiement = $invoicestatic->getSommePaiement();
$var=!$var;
print '<tr '.$bc[$var].'>';
print '<td>';
$invoicestatic->id=$objp->facid;
$invoicestatic->ref=$objp->facnumber;
print $invoicestatic->getNomUrl(1);
print "</td>\n";
$societestatic->fetch($objp->socid);
print '<td>'.$societestatic->getNomUrl(1).'</td>';
print "<td>".$objp->code_client."</td>\n";
print '<td align="center">';
print dol_print_date($db->jdate($objp->datef),'day')."</td>";
print '<td align="center">'.$objp->qty."</td>\n";
print '<td align="right">'.price($objp->total_ht)."</td>\n";
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5).'</td>';
print '<td align="right">'.$invoicestatic->LibStatut($objp->paye,$objp->statut,5,$paiement,$objp->type).'</td>';
print "</tr>\n";
$i++;