Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into dev_NEW_copyeventfiles

This commit is contained in:
florian HENRY 2017-01-25 11:03:42 +01:00
commit 32441d9ee3
10 changed files with 232 additions and 106 deletions

View File

@ -125,23 +125,13 @@ $langs->load("cashdesk");
<td><input class="texte1_off maxwidth50onsmartphone" type="text" name="txtTotal" value="" disabled /></td><td></td>
<!-- Choix du taux de TVA -->
<td class="select_tva">
<?php //var_dump($tab_tva); ?>
<select name="selTva" onchange="javascript: modif();" >
<?php
$tva_tx = $obj_facturation->tva(); // Try to get a previously entered VAT rowid. First time, this will return empty.
$tab_tva_size=count($tab_tva); // $tab_tva contains list of possible vat array('rowid'=> , 'taux'=> )
for ($i=0;$i < $tab_tva_size;$i++)
{
if ($tva_tx == $tab_tva[$i]['rowid'])
$selected = 'selected';
else
$selected = '';
echo '<option '.$selected.' value="'.$tab_tva[$i]['rowid'].'">'.$tab_tva[$i]['taux'].'</option>'."\n ";
}
?>
</select>
<?php //var_dump($tab_tva);
$tva_tx = $obj_facturation->tva(); // Try to get a previously entered VAT rowid. First time, this will return empty.
$buyer = new Societe($db);
if ($_SESSION["CASHDESK_ID_THIRDPARTY"] > 0) $buyer->fetch($_SESSION["CASHDESK_ID_THIRDPARTY"]);
echo $form->load_tva('selTva', (isset($_POST["selTva"])?GETPOST("selTva",'alpha',2):-1), $mysoc, $buyer, 0, 0, '', false, -1);
?>
</td>
</tr>
</table>

View File

@ -47,15 +47,25 @@ switch ($action)
case 'valide_achat':
$thirdpartyid = $_SESSION['CASHDESK_ID_THIRDPARTY'];
$company=new Societe($db);
$company->fetch($conf->global->CASHDESK_ID_THIRDPARTY);
$company->fetch($thirdpartyid);
$invoice=new Facture($db);
$invoice->date=dol_now();
$invoice->type= Facture::TYPE_STANDARD;
// TODO
// To use a specific numbering module for POS, reset $conf->global->FACTURE_ADDON and other vars here
// and restore after values just after
$num=$invoice->getNextNumRef($company);
// TODO Restore save values
$obj_facturation->numInvoice($num);
$obj_facturation->getSetPaymentMode($_POST['hdnChoix']);

View File

@ -484,24 +484,28 @@ if ($id > 0)
print '</tr></table>';
print '</td><td>';
if ($action == 'editlevel')
{
$formcompany->form_prospect_level($_SERVER['PHP_SELF'].'?socid='.$object->id,$object->fk_prospectlevel,'prospect_level_id',1);
else
print $object->getLibProspLevel();
print "</td>";
print '</tr>';
// Status
$object->loadCacheOfProspStatus();
print '<tr><td>'.$langs->trans("StatusProsp").'</td><td colspan="3">'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
print ' &nbsp; &nbsp; ';
print '<div class="floatright">';
foreach($object->cacheprospectstatus as $key => $val)
{
$titlealt='default';
if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm">'.img_action($titlealt,$val['code']).'</a>';
}
print '</div></td></tr>';
}
else
{
print $object->getLibProspLevel();
}
print "</td>";
print '</tr>';
// Status
$object->loadCacheOfProspStatus();
print '<tr><td>'.$langs->trans("StatusProsp").'</td><td>'.$object->getLibProspCommStatut(4, $object->cacheprospectstatus[$object->stcomm_id]['label']);
print ' &nbsp; &nbsp; ';
print '<div class="floatright">';
foreach($object->cacheprospectstatus as $key => $val)
{
$titlealt='default';
if (! empty($val['code']) && ! in_array($val['code'], array('ST_NO', 'ST_NEVER', 'ST_TODO', 'ST_PEND', 'ST_DONE'))) $titlealt=$val['label'];
if ($object->stcomm_id != $val['id']) print '<a class="pictosubstatus" href="'.$_SERVER["PHP_SELF"].'?socid='.$object->id.'&stcomm='.$val['code'].'&action=setstcomm">'.img_action($titlealt,$val['code']).'</a>';
}
print '</div></td></tr>';
print "</table>";
}
@ -575,7 +579,7 @@ if ($id > 0)
$warn = '';
if ($object->outstanding_limit != '' && $object->outstanding_limit < $outstandingOpened)
{
$warn = img_warning($langs->trans("OutstandingBillReached"));
$warn = ' '.img_warning($langs->trans("OutstandingBillReached"));
}
$text=$langs->trans("CurrentOutstandingBill");
$link=DOL_URL_ROOT.'/compta/recap-compta.php?socid='.$object->id;
@ -583,7 +587,7 @@ if ($id > 0)
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
$boxstat.='<div class="boxstats">';
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
$boxstat.='<span class="boxstatsindicator'.($outstandingOpened>0?' amountremaintopay':'').'">'.price($outstandingOpened).$warn.'</span>';
$boxstat.='<span class="boxstatsindicator'.($outstandingOpened>0?' amountremaintopay':'').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}

View File

@ -3120,52 +3120,6 @@ class Facture extends CommonInvoice
}
/**
* Return amount (with tax) of all credit notes and deposits invoices used by invoice
*
* @param int $multicurrency Return multicurrency_amount instead of amount
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
*/
function getSumCreditNotesUsed($multicurrency=0)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
if ($result >= 0)
{
return $result;
}
else
{
$this->error=$discountstatic->error;
return -1;
}
}
/**
* Return amount (with tax) of all deposits invoices used by invoice
*
* @param int $multicurrency Return multicurrency_amount instead of amount
* @return int <0 if KO, Sum of deposits amount otherwise
*/
function getSumDepositsUsed($multicurrency=0)
{
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
if ($result >= 0)
{
return $result;
}
else
{
$this->error=$discountstatic->error;
return -1;
}
}
/**
* Return next reference of customer invoice not already used (or last reference)
* according to numbering module defined into constant FACTURE_ADDON

View File

@ -88,6 +88,7 @@ abstract class CommonInvoice extends CommonObject
*/
const STATUS_ABANDONED = 3;
/**
* Return amount of payments already done
*
@ -124,6 +125,65 @@ abstract class CommonInvoice extends CommonObject
}
}
/**
* Return amount (with tax) of all credit notes and deposits invoices used by invoice
*
* @param int $multicurrency Return multicurrency_amount instead of amount
* @return int <0 if KO, Sum of credit notes and deposits amount otherwise
*/
function getSumCreditNotesUsed($multicurrency=0)
{
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
// TODO
return 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumCreditNotesUsed($this, $multicurrency);
if ($result >= 0)
{
return $result;
}
else
{
$this->error=$discountstatic->error;
return -1;
}
}
/**
* Return amount (with tax) of all deposits invoices used by invoice
*
* @param int $multicurrency Return multicurrency_amount instead of amount
* @return int <0 if KO, Sum of deposits amount otherwise
*/
function getSumDepositsUsed($multicurrency=0)
{
if ($this->element == 'facture_fourn' || $this->element == 'invoice_supplier')
{
// TODO
return 0;
}
require_once DOL_DOCUMENT_ROOT.'/core/class/discount.class.php';
$discountstatic=new DiscountAbsolute($this->db);
$result=$discountstatic->getSumDepositsUsed($this, $multicurrency);
if ($result >= 0)
{
return $result;
}
else
{
$this->error=$discountstatic->error;
return -1;
}
}
/**
* Renvoie tableau des ids de facture avoir issus de la facture
*

View File

@ -4257,7 +4257,7 @@ class Form
dol_syslog(__METHOD__, LOG_DEBUG);
$sql = "SELECT DISTINCT t.code, t.taux, t.recuperableonly";
$sql = "SELECT DISTINCT t.rowid, t.code, t.taux, t.recuperableonly";
$sql.= " FROM ".MAIN_DB_PREFIX."c_tva as t, ".MAIN_DB_PREFIX."c_country as c";
$sql.= " WHERE t.fk_pays = c.rowid";
$sql.= " AND t.active > 0";
@ -4273,6 +4273,7 @@ class Form
for ($i = 0; $i < $num; $i++)
{
$obj = $this->db->fetch_object($resql);
$this->cache_vatrates[$i]['rowid'] = $obj->rowid;
$this->cache_vatrates[$i]['code'] = $obj->code;
$this->cache_vatrates[$i]['txtva'] = $obj->taux;
$this->cache_vatrates[$i]['libtva'] = $obj->taux.'%'.($obj->code?' ('.$obj->code.')':''); // Label must contains only 0-9 , . % or *
@ -4302,9 +4303,9 @@ class Form
* @param float|string $selectedrate Force preselected vat rate. Can be '8.5' or '8.5 (NOO)' for example. Use '' for no forcing.
* @param Societe $societe_vendeuse Thirdparty seller
* @param Societe $societe_acheteuse Thirdparty buyer
* @param int $idprod Id product
* @param int $idprod Id product. O if unknown of NA.
* @param int $info_bits Miscellaneous information on line (1 for NPR)
* @param int $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
* @param int|string $type ''=Unknown, 0=Product, 1=Service (Used if idprod not defined)
* Si vendeur non assujeti a TVA, TVA par defaut=0. Fin de regle.
* Si le (pays vendeur = pays acheteur) alors la TVA par defaut=TVA du produit vendu. Fin de regle.
* Si (vendeur et acheteur dans Communaute europeenne) et bien vendu = moyen de transports neuf (auto, bateau, avion), TVA par defaut=0 (La TVA doit etre paye par l'acheteur au centre d'impots de son pays et non au vendeur). Fin de regle.
@ -4312,10 +4313,10 @@ class Form
* Si vendeur et acheteur dans Communauté européenne et acheteur= entreprise alors TVA par défaut=0. Fin de règle.
* Sinon la TVA proposee par defaut=0. Fin de regle.
* @param bool $options_only Return HTML options lines only (for ajax treatment)
* @param int $addcode Add code into key in select list
* @param int $mode 1=Add code into key in select list
* @return string
*/
function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $addcode=0)
function load_tva($htmlname='tauxtva', $selectedrate='', $societe_vendeuse='', $societe_acheteuse='', $idprod=0, $info_bits=0, $type='', $options_only=false, $mode=0)
{
global $langs,$conf,$mysoc;
@ -4427,10 +4428,13 @@ class Form
// Keep only 0 if seller is not subject to VAT
if ($disabled && $rate['txtva'] != 0) continue;
$return.= '<option value="'.$rate['txtva'];
$return.= $rate['nprtva'] ? '*': '';
if ($addcode && $rate['code']) $return.=' ('.$rate['code'].')';
$return.= '"';
// Define key to use into select list
$key = $rate['txtva'];
$key.= $rate['nprtva'] ? '*': '';
if ($mode > 0 && $rate['code']) $key.=' ('.$rate['code'].')';
if ($mode < 0) $key = $rate['rowid'];
$return.= '<option value="'.$key.'"';
if (! $selectedfound)
{
if ($defaultcode) // If defaultcode is defined, we used it in priority to select combo option instead of using rate+npr flag

View File

@ -138,7 +138,7 @@ class FormCompany
*/
function form_prospect_level($page, $selected='', $htmlname='prospect_level_id', $empty=0)
{
global $langs;
global $user, $langs;
print '<form method="post" action="'.$page.'">';
print '<input type="hidden" name="action" value="setprospectlevel">';
@ -171,7 +171,7 @@ class FormCompany
print Form::selectarray($htmlname, $options, $selected);
}
else dol_print_error($this->db);
if (! empty($htmlname) && $user->admin) print ' '.info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionarySetup"),1);
print '<input type="submit" class="button valignmiddle" value="'.$langs->trans("Modify").'">';
print '</form>';
}

View File

@ -277,12 +277,94 @@ if ($object->id > 0)
print '</div><div class="fichehalfright"><div class="ficheaddleft">';
$boxstat = '';
// Nbre max d'elements des petites listes
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
// Lien recap
$boxstat.='<div class="box">';
$boxstat.='<table summary="'.dol_escape_htmltag($langs->trans("DolibarrStateBoard")).'" class="noborder boxtable" width="100%">';
$boxstat.='<tr class="impair"><td colspan="2" class="tdboxstats nohover">';
if ($conf->supplier_proposal->enabled)
{
// Box proposals
$tmp = $object->getOutstandingProposals('supplier');
$outstandingOpened=$tmp['opened'];
$outstandingTotal=$tmp['total_ht'];
$outstandingTotalIncTax=$tmp['total_ttc'];
$text=$langs->trans("OverAllSupplierProposals");
$link='';
$icon='bill';
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
$boxstat.='<div class="boxstats">';
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
$boxstat.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}
if ($conf->fournisseur->enabled)
{
// Box proposals
$tmp = $object->getOutstandingOrders('supplier');
$outstandingOpened=$tmp['opened'];
$outstandingTotal=$tmp['total_ht'];
$outstandingTotalIncTax=$tmp['total_ttc'];
$text=$langs->trans("OverAllOrders");
$link='';
$icon='bill';
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
$boxstat.='<div class="boxstats">';
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
$boxstat.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}
if ($conf->fournisseur->enabled)
{
$tmp = $object->getOutstandingBills('supplier');
$outstandingOpened=$tmp['opened'];
$outstandingTotal=$tmp['total_ht'];
$outstandingTotalIncTax=$tmp['total_ttc'];
$text=$langs->trans("OverAllInvoices");
$link='';
$icon='bill';
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
$boxstat.='<div class="boxstats">';
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
$boxstat.='<span class="boxstatsindicator">'.price($outstandingTotal, 1, $langs, 1, -1, -1, $conf->currency).'</span>';
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
// Box outstanding bill
$text=$langs->trans("CurrentOutstandingBill");
$link=DOL_URL_ROOT.'/fourn/recap-fourn.php?socid='.$object->id;
$icon='bill';
if ($link) $boxstat.='<a href="'.$link.'" class="boxstatsindicator thumbstat nobold nounderline">';
$boxstat.='<div class="boxstats">';
$boxstat.='<span class="boxstatstext">'.img_object("",$icon).' '.$text.'</span><br>';
$boxstat.='<span class="boxstatsindicator'.($outstandingOpened>0?' amountremaintopay':'').'">'.price($outstandingOpened, 1, $langs, 1, -1, -1, $conf->currency).$warn.'</span>';
$boxstat.='</div>';
if ($link) $boxstat.='</a>';
}
$boxstat.='</td></tr>';
$boxstat.='</table>';
$boxstat.='</div>';
print $boxstat;
$var=true;
$MAXLIST=$conf->global->MAIN_SIZE_SHORTLIST_LIMIT;
// Lien recap
/*
print '<table class="noborder" width="100%">';
print '<tr class="liste_titre">';
print '<td colspan="4"><table width="100%" class="nobordernopadding"><tr><td>'.$langs->trans("Summary").'</td>';
@ -290,7 +372,7 @@ if ($object->id > 0)
print '</tr>';
print '</table>';
print '<br>';
*/
/*
* List of products

View File

@ -81,6 +81,7 @@ PaymentBankAccount=Payment bank account
OverAllProposals=Total proposals
OverAllOrders=Total orders
OverAllInvoices=Total invoices
OverAllSupplierProposals=Total price requests
##### Local Taxes #####
LocalTax1IsUsed=Use second tax
LocalTax1IsUsedES= RE is used

View File

@ -3341,11 +3341,15 @@ class Societe extends CommonObject
/**
* Return amount of order not paid and total
*
* @return array array('opened'=>Amount, 'total'=>Total amount)
* @param string $mode 'customer' or 'supplier'
* @return array array('opened'=>Amount, 'total'=>Total amount)
*/
function getOutstandingProposals()
function getOutstandingProposals($mode='customer')
{
$sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX."propal as f";
$table='propal';
if ($mode == 'supplier') $table = 'supplier_proposal';
$sql = "SELECT rowid, total_ht, total as total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ". $this->id;
dol_syslog("getOutstandingProposals", LOG_DEBUG);
@ -3372,11 +3376,15 @@ class Societe extends CommonObject
/**
* Return amount of order not paid and total
*
* @param string $mode 'customer' or 'supplier'
* @return array array('opened'=>Amount, 'total'=>Total amount)
*/
function getOutstandingOrders()
function getOutstandingOrders($mode='customer')
{
$sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX."commande as f";
$table='commande';
if ($mode == 'supplier') $table = 'commande_fournisseur';
$sql = "SELECT rowid, total_ht, total_ttc, fk_statut FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ". $this->id;
dol_syslog("getOutstandingOrders", LOG_DEBUG);
@ -3403,10 +3411,14 @@ class Societe extends CommonObject
/**
* Return amount of bill not paid and total
*
* @param string $mode 'customer' or 'supplier'
* @return array array('opened'=>Amount, 'total'=>Total amount)
*/
function getOutstandingBills()
function getOutstandingBills($mode='customer')
{
$table='facture';
if ($mode == 'supplier') $table = 'facture_fourn';
/* Accurate value of remain to pay is to sum remaintopay for each invoice
$paiement = $invoice->getSommePaiement();
$creditnotes=$invoice->getSumCreditNotesUsed();
@ -3414,7 +3426,8 @@ class Societe extends CommonObject
$alreadypayed=price2num($paiement + $creditnotes + $deposits,'MT');
$remaintopay=price2num($invoice->total_ttc - $paiement - $creditnotes - $deposits,'MT');
*/
$sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX."facture as f";
if ($mode == 'supplier') $sql = "SELECT rowid, total_ht as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
else $sql = "SELECT rowid, total as total_ht, total_ttc, paye, fk_statut, close_code FROM ".MAIN_DB_PREFIX.$table." as f";
$sql .= " WHERE fk_soc = ". $this->id;
dol_syslog("getOutstandingBills", LOG_DEBUG);
@ -3424,8 +3437,16 @@ class Societe extends CommonObject
$outstandingOpened = 0;
$outstandingTotal = 0;
$outstandingTotalIncTax = 0;
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$tmpobject=new Facture($this->db);
if ($mode == 'supplier')
{
require_once DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php';
$tmpobject=new FactureFournisseur($this->db);
}
else
{
require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
$tmpobject=new Facture($this->db);
}
while($obj=$this->db->fetch_object($resql)) {
$tmpobject->id=$obj->rowid;
if ($obj->fk_statut != 0 // Not a draft