Merge branch 'develop' of https://github.com/Dolibarr/dolibarr.git into develop
This commit is contained in:
commit
df930d08b2
@ -1436,18 +1436,21 @@ class AccountLine extends CommonObject
|
||||
if ($withpicto) $result.=($lien.img_object($langs->trans("ShowTransaction"),'account').$lienfin.' ');
|
||||
$result.=$lien.$this->rowid.$lienfin;
|
||||
|
||||
if ($option == 'showall' || $option == 'showconciliated') $result.=' (';
|
||||
if ($option == 'showall')
|
||||
{
|
||||
$result.=' (';
|
||||
$result.=$langs->trans("BankAccount").': ';
|
||||
$accountstatic=new Account($this->db);
|
||||
$accountstatic->id=$this->fk_account;
|
||||
$accountstatic->label=$this->bank_account_label;
|
||||
$result.=$accountstatic->getNomUrl(0).', ';
|
||||
}
|
||||
if ($option == 'showall' || $option == 'showconciliated')
|
||||
{
|
||||
$result.=$langs->trans("BankLineConciliated").': ';
|
||||
$result.=yn($this->rappro);
|
||||
$result.=')';
|
||||
}
|
||||
if ($option == 'showall' || $option == 'showconciliated') $result.=')';
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
@ -1788,8 +1788,8 @@ class Facture extends CommonInvoice
|
||||
// Rename directory if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||
{
|
||||
// On renomme repertoire facture ($this->ref = ancienne ref, $num = nouvelle ref)
|
||||
// afin de ne pas perdre les fichiers attaches
|
||||
// Rename of object directory ($this->ref = old ref, $num = new ref)
|
||||
// to not lose the linked files
|
||||
$facref = dol_sanitizeFileName($this->ref);
|
||||
$snumfa = dol_sanitizeFileName($num);
|
||||
$dirsource = $conf->facture->dir_output.'/'.$facref;
|
||||
@ -1977,7 +1977,7 @@ class Facture extends CommonInvoice
|
||||
function addline($desc, $pu_ht, $qty, $txtva, $txlocaltax1=0, $txlocaltax2=0, $fk_product=0, $remise_percent=0, $date_start='', $date_end='', $ventil=0, $info_bits=0, $fk_remise_except='', $price_base_type='HT', $pu_ttc=0, $type=0, $rang=-1, $special_code=0, $origin='', $origin_id=0, $fk_parent_line=0, $fk_fournprice=null, $pa_ht=0, $label='',$array_option=0)
|
||||
{
|
||||
global $mysoc;
|
||||
|
||||
|
||||
$facid=$this->id;
|
||||
|
||||
dol_syslog(get_class($this)."::Addline facid=$facid,desc=$desc,pu_ht=$pu_ht,qty=$qty,txtva=$txtva, txlocaltax1=$txlocaltax1, txlocaltax2=$txlocaltax2, fk_product=$fk_product,remise_percent=$remise_percent,date_start=$date_start,date_end=$date_end,ventil=$ventil,info_bits=$info_bits,fk_remise_except=$fk_remise_except,price_base_type=$price_base_type,pu_ttc=$pu_ttc,type=$type", LOG_DEBUG);
|
||||
@ -2023,9 +2023,9 @@ class Facture extends CommonInvoice
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
|
||||
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);
|
||||
|
||||
|
||||
$tabprice = calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type,'',$localtaxes_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
@ -2148,7 +2148,7 @@ class Facture extends CommonInvoice
|
||||
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=0, $fk_parent_line=0, $skip_update_total=0, $fk_fournprice=null, $pa_ht=0, $label='', $special_code=0, $array_option=0)
|
||||
{
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/price.lib.php';
|
||||
|
||||
|
||||
global $mysoc;
|
||||
|
||||
dol_syslog(get_class($this)."::updateline $rowid, $desc, $pu, $qty, $remise_percent, $date_start, $date_end, $txtva, $txlocaltax1, $txlocaltax2, $price_base_type, $info_bits, $type, $fk_parent_line", LOG_DEBUG);
|
||||
@ -2176,9 +2176,9 @@ class Facture extends CommonInvoice
|
||||
// Calculate total with, without tax and tax from qty, pu, remise_percent and txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
|
||||
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);
|
||||
|
||||
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, $type,'',$localtaxes_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
|
||||
@ -193,7 +193,7 @@ dol_fiche_head($head, $hselected, $langs->trans("PaymentCustomerInvoice"), 0, 'p
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete','',0,2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -203,7 +203,7 @@ if ($action == 'valide')
|
||||
{
|
||||
$facid = $_GET['facid'];
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id.'&facid='.$facid, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide','',0,2);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -230,7 +230,7 @@ print $form->editfieldval("Numero",'num_paiement',$object->numero,$object,$objec
|
||||
print '</td></tr>';
|
||||
|
||||
// Amount
|
||||
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant).' '.$langs->trans('Currency'.$conf->currency).'</td></tr>';
|
||||
print '<tr><td valign="top">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant,'',$langs,0,0,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
// Note
|
||||
print '<tr><td valign="top">'.$form->editfieldkey("Note",'note',$object->note,$object,$user->rights->facture->paiement).'</td><td colspan="3">';
|
||||
@ -248,15 +248,25 @@ if (! empty($conf->banque->enabled))
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('BankTransactionLine').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $bankline->getNomUrl(1,0,'showall');
|
||||
print $bankline->getNomUrl(1,0,'showconciliated');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('BankAccount').'</td>';
|
||||
print '<td colspan="3">';
|
||||
$accountstatic=new Account($db);
|
||||
$accountstatic->id=$bankline->fk_account;
|
||||
$accountstatic->label=$bankline->bank_account_ref.' - '.$bankline->bank_account_label;
|
||||
print $accountstatic->getNomUrl(0);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
if($object->type_code == 'CHQ' && $bankline->fk_bordereau > 0) {
|
||||
dol_include_once('/compta/paiement/cheque/class/remisecheque.class.php');
|
||||
$bordereau = new RemiseCheque($db);
|
||||
$bordereau->fetch($bankline->fk_bordereau);
|
||||
|
||||
|
||||
print '<tr>';
|
||||
print '<td>'.$langs->trans('CheckReceipt').'</td>';
|
||||
print '<td colspan="3">';
|
||||
|
||||
@ -274,54 +274,63 @@ class Contrat extends CommonObject
|
||||
}
|
||||
|
||||
/**
|
||||
* Validate a contract
|
||||
* Validate a contract
|
||||
*
|
||||
* @param User $user Objet User
|
||||
* @return int <0 if KO, >0 if OK
|
||||
* @param User $user Objet User
|
||||
* @param string $force_number Reference to force on contract (not implemented yet)
|
||||
* @return int <0 if KO, >0 if OK
|
||||
*/
|
||||
function validate($user)
|
||||
function validate($user, $force_number='')
|
||||
{
|
||||
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
global $langs, $conf;
|
||||
|
||||
$now=dol_now();
|
||||
|
||||
$error=0;
|
||||
dol_syslog(get_class($this).'::validate user='.$user->id.', force_number='.$force_number);
|
||||
|
||||
// Definition du nom de module de numerotation de commande
|
||||
$soc = new Societe($this->db);
|
||||
$soc->fetch($this->socid);
|
||||
|
||||
// Class of company linked to order
|
||||
$result=$soc->set_as_client();
|
||||
$this->db->begin();
|
||||
|
||||
$this->fetch_thirdparty();
|
||||
|
||||
// A contract is validated so we can move thirdparty to status customer
|
||||
$result=$this->thirdparty->set_as_client();
|
||||
|
||||
// Define new ref
|
||||
if (! $error && (preg_match('/^[\(]?PROV/i', $this->ref)))
|
||||
{
|
||||
$num = $this->getNextNumRef($soc);
|
||||
$num = $this->getNextNumRef($this->thirdparty);
|
||||
}
|
||||
else
|
||||
{
|
||||
$num = $this->ref;
|
||||
}
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET ref = '".$num."', statut = 1";
|
||||
$sql .= " WHERE rowid = ".$this->id . " AND statut = 0";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
if ($num)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('CONTRACT_VALIDATE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
|
||||
$sql = "UPDATE ".MAIN_DB_PREFIX."contrat SET ref = '".$num."', statut = 1";
|
||||
//$sql.= ", fk_user_valid = ".$user->id.", date_valid = '".$this->db->idate($now)."'";
|
||||
$sql .= " WHERE rowid = ".$this->id . " AND statut = 0";
|
||||
|
||||
dol_syslog(get_class($this)."::validate sql=".$sql);
|
||||
$resql = $this->db->query($sql);
|
||||
if (! $resql)
|
||||
{
|
||||
dol_syslog(get_class($this)."::validate Echec update - 10 - sql=".$sql, LOG_ERR);
|
||||
dol_print_error($this->db);
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->oldref = '';
|
||||
|
||||
// Rename directory if dir was a temporary ref
|
||||
if (preg_match('/^[\(]?PROV/i', $this->ref))
|
||||
{
|
||||
// Rename of propal directory ($this->ref = old ref, $num = new ref)
|
||||
// Rename of object directory ($this->ref = old ref, $num = new ref)
|
||||
// to not lose the linked files
|
||||
$facref = dol_sanitizeFileName($this->ref);
|
||||
$snumfa = dol_sanitizeFileName($num);
|
||||
@ -330,28 +339,56 @@ class Contrat extends CommonObject
|
||||
if (file_exists($dirsource))
|
||||
{
|
||||
dol_syslog(get_class($this)."::validate rename dir ".$dirsource." into ".$dirdest);
|
||||
|
||||
|
||||
if (@rename($dirsource, $dirdest))
|
||||
{
|
||||
$this->oldref = $facref;
|
||||
|
||||
dol_syslog("Rename ok");
|
||||
// Deleting old PDF in new rep
|
||||
dol_delete_file($conf->contract->dir_output.'/'.$snumfa.'/'.$facref.'*.*');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
|
||||
// Set new ref and define current statut
|
||||
if (! $error)
|
||||
{
|
||||
return -1;
|
||||
$this->ref = $num;
|
||||
$this->statut=1;
|
||||
$this->brouillon=0;
|
||||
$this->date_validation=$now;
|
||||
}
|
||||
|
||||
// Trigger calls
|
||||
if (! $error)
|
||||
{
|
||||
// Appel des triggers
|
||||
include_once DOL_DOCUMENT_ROOT . '/core/class/interfaces.class.php';
|
||||
$interface=new Interfaces($this->db);
|
||||
$result=$interface->run_triggers('CONTRACT_VALIDATE',$this,$user,$langs,$conf);
|
||||
if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||
// Fin appel triggers
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->error=$this->db->error();
|
||||
$error++;
|
||||
}
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$this->db->commit();
|
||||
return 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->db->rollback();
|
||||
$this->error=$this->db->lasterror();
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -966,19 +1003,19 @@ class Contrat extends CommonObject
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
|
||||
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);
|
||||
|
||||
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $txtva, $txlocaltax1, $txlocaltax2, 0, $price_base_type, $info_bits, 1,'', $localtaxes_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1= $tabprice[9];
|
||||
$total_localtax2= $tabprice[10];
|
||||
|
||||
|
||||
$localtax1_type=$localtaxes_type[0];
|
||||
$localtax2_type=$localtaxes_type[2];
|
||||
|
||||
|
||||
// TODO A virer
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
$remise = 0;
|
||||
@ -1114,19 +1151,19 @@ class Contrat extends CommonObject
|
||||
// qty, pu, remise_percent et txtva
|
||||
// TRES IMPORTANT: C'est au moment de l'insertion ligne qu'on doit stocker
|
||||
// la part ht, tva et ttc, et ce au niveau de la ligne qui a son propre taux tva.
|
||||
|
||||
|
||||
$localtaxes_type=getLocalTaxesFromRate($txtva,0,$mysoc);
|
||||
|
||||
|
||||
$tabprice=calcul_price_total($qty, $pu, $remise_percent, $tvatx, $localtaxtx1, $txlocaltaxtx2, 0, $price_base_type, $info_bits, 1, '', $localtaxes_type);
|
||||
$total_ht = $tabprice[0];
|
||||
$total_tva = $tabprice[1];
|
||||
$total_ttc = $tabprice[2];
|
||||
$total_localtax1= $tabprice[9];
|
||||
$total_localtax2= $tabprice[10];
|
||||
|
||||
|
||||
$localtax1_type=$localtaxes_type[0];
|
||||
$localtax2_type=$localtaxes_type[2];
|
||||
|
||||
|
||||
// TODO A virer
|
||||
// Anciens indicateurs: $price, $remise (a ne plus utiliser)
|
||||
$remise = 0;
|
||||
|
||||
@ -515,22 +515,7 @@ function quotedPrintEncode($str,$forcal=0)
|
||||
function quotedPrintDecode($str)
|
||||
{
|
||||
$out = preg_replace('/=\r?\n/', '', $str);
|
||||
/*
|
||||
* preg_replace /e modifier is deprecated in PHP 5.5
|
||||
* but anonymous functions for use in preg_replace_callback are only available from 5.3.0
|
||||
*/
|
||||
if (version_compare(PHP_VERSION, '5.3.0') >= 0) {
|
||||
$out = preg_replace_callback(
|
||||
'/=([A-F0-9]{2})/',
|
||||
function ($m) {
|
||||
return chr(hexdec($m[1]));
|
||||
},
|
||||
$out
|
||||
);
|
||||
} else {
|
||||
$out = preg_replace('/=([A-F0-9]{2})/e', chr(hexdec('\\1')), $out);
|
||||
}
|
||||
|
||||
$out = quoted_printable_decode($out); // Available with PHP 4+
|
||||
return trim($out);
|
||||
}
|
||||
|
||||
|
||||
@ -115,7 +115,7 @@ if ($action == 'setnum' && ! empty($_POST['num_paiement']))
|
||||
}
|
||||
}
|
||||
|
||||
if ($action == 'setdate' && ! empty($_POST['datepday']))
|
||||
if ($action == 'setdatep' && ! empty($_POST['datepday']))
|
||||
{
|
||||
$object->fetch($id);
|
||||
$datepaye = dol_mktime(12, 0, 0, $_POST['datepmonth'], $_POST['datepday'], $_POST['datepyear']);
|
||||
@ -162,7 +162,7 @@ if ($result > 0)
|
||||
if ($action == 'delete')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("DeletePayment"), $langs->trans("ConfirmDeletePayment"), 'confirm_delete');
|
||||
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
@ -171,7 +171,7 @@ if ($result > 0)
|
||||
if ($action == 'valide')
|
||||
{
|
||||
print $form->formconfirm($_SERVER['PHP_SELF'].'?id='.$object->id, $langs->trans("ValidatePayment"), $langs->trans("ConfirmValidatePayment"), 'confirm_valide');
|
||||
|
||||
|
||||
}
|
||||
|
||||
print '<table class="border" width="100%">';
|
||||
@ -195,7 +195,7 @@ if ($result > 0)
|
||||
print '</td></tr>';
|
||||
|
||||
// Amount
|
||||
print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant).' '.$langs->trans('Currency'.$conf->currency).'</td></tr>';
|
||||
print '<tr><td valign="top" colspan="2">'.$langs->trans('Amount').'</td><td colspan="3">'.price($object->montant,'',$langs,0,0,-1,$conf->currency).'</td></tr>';
|
||||
|
||||
if (! empty($conf->global->BILL_ADD_PAYMENT_VALIDATION))
|
||||
{
|
||||
@ -218,9 +218,19 @@ if ($result > 0)
|
||||
print '<tr>';
|
||||
print '<td colspan="2">'.$langs->trans('BankTransactionLine').'</td>';
|
||||
print '<td colspan="3">';
|
||||
print $bankline->getNomUrl(1,0,'showall');
|
||||
print $bankline->getNomUrl(1,0,'showconciliated');
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
|
||||
print '<tr>';
|
||||
print '<td colspan="2">'.$langs->trans('BankAccount').'</td>';
|
||||
print '<td colspan="3">';
|
||||
$accountstatic=new Account($db);
|
||||
$accountstatic->id=$bankline->fk_account;
|
||||
$accountstatic->label=$bankline->bank_account_ref.' - '.$bankline->bank_account_label;
|
||||
print $accountstatic->getNomUrl(0);
|
||||
print '</td>';
|
||||
print '</tr>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -301,6 +301,7 @@ ALTER TABLE llx_facture_fourn MODIFY COLUMN fk_cond_reglement integer NULL;
|
||||
|
||||
insert into llx_c_action_trigger (rowid,code,label,description,elementtype,rang) values (9,'COMPANY_SENTBYMAIL','Mails sent from third party card','Executed when you send email from third party card','societe',1);
|
||||
|
||||
ALTER TABLE llx_contratdet ADD column product_type integer DEFAULT 1 after total_ttc;
|
||||
|
||||
create table llx_contrat_extrafields
|
||||
(
|
||||
|
||||
@ -52,6 +52,7 @@ create table llx_contratdet
|
||||
total_localtax1 double(24,8) DEFAULT 0, -- Total Local tax 1 de la ligne
|
||||
total_localtax2 double(24,8) DEFAULT 0, -- Total Local tax 2 de la ligne
|
||||
total_ttc double(24,8) DEFAULT 0, -- Total TTC de la ligne toute quantite et incluant remise ligne et globale
|
||||
product_type integer DEFAULT 1, -- Product type (1=service by default)
|
||||
info_bits integer DEFAULT 0, -- TVA NPR ou non
|
||||
|
||||
buy_price_ht double(24,8) DEFAULT NULL, -- buying price
|
||||
|
||||
@ -124,8 +124,8 @@ function analyse_sql_and_script(&$var, $type)
|
||||
$var[$key] = $value;
|
||||
}
|
||||
else
|
||||
{
|
||||
print 'Access refused by SQL/Script injection protection in main.inc.php';
|
||||
{
|
||||
print 'Access refused by SQL/Script injection protection in main.inc.php (type='.htmlentities($type).' key='.htmlentities($key).' value='.htmlentities($value).' page='.htmlentities($_SERVER["REQUEST_URI"]).')';
|
||||
exit;
|
||||
}
|
||||
}
|
||||
|
||||
@ -65,7 +65,6 @@ class Societe extends CommonObject
|
||||
var $country_code;
|
||||
var $country;
|
||||
|
||||
var $tel; // deprecated
|
||||
var $phone;
|
||||
var $fax;
|
||||
var $email;
|
||||
@ -402,7 +401,7 @@ class Societe extends CommonObject
|
||||
$this->zip = $this->zip?trim($this->zip):trim($this->zip);
|
||||
$this->town = $this->town?trim($this->town):trim($this->town);
|
||||
$this->state_id = trim($this->state_id);
|
||||
$this->country_id = ($this->country_id > 0)?$this->country_id:$this->country_id;
|
||||
$this->country_id = ($this->country_id > 0)?$this->country_id:0;
|
||||
$this->phone = trim($this->phone);
|
||||
$this->phone = preg_replace("/\s/","",$this->phone);
|
||||
$this->phone = preg_replace("/\./","",$this->phone);
|
||||
|
||||
@ -174,6 +174,7 @@ if (empty($reshook))
|
||||
// Fill array 'array_options' with data from add form
|
||||
$ret = $extrafields->setOptionalsFromPost($extralabels,$object);
|
||||
|
||||
|
||||
if (GETPOST('deletephoto')) $object->logo = '';
|
||||
else if (! empty($_FILES['photo']['name'])) $object->logo = dol_sanitizeFileName($_FILES['photo']['name']);
|
||||
|
||||
@ -200,7 +201,7 @@ if (empty($reshook))
|
||||
}
|
||||
|
||||
// We set country_id, country_code and country for the selected country
|
||||
$object->country_id=GETPOST('country_id')?GETPOST('country_id'):$mysoc->country_id;
|
||||
$object->country_id=GETPOST('country_id')!=''?GETPOST('country_id'):$mysoc->country_id;
|
||||
if ($object->country_id)
|
||||
{
|
||||
$tmparray=getCountry($object->country_id,'all');
|
||||
@ -827,7 +828,7 @@ else
|
||||
|
||||
// Country
|
||||
print '<tr><td width="25%">'.$langs->trans('Country').'</td><td colspan="3">';
|
||||
print $form->select_country($object->country_id,'country_id');
|
||||
print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1207,7 +1208,7 @@ else
|
||||
print '<input type="text" name="code_fournisseur" size="16" value="'.$object->code_fournisseur.'" maxlength="15">';
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
print $object->code_fournisseur;
|
||||
print '<input type="hidden" name="code_fournisseur" value="'.$object->code_fournisseur.'">';
|
||||
}
|
||||
@ -1245,7 +1246,7 @@ else
|
||||
|
||||
// Country
|
||||
print '<tr><td>'.$langs->trans('Country').'</td><td colspan="3">';
|
||||
print $form->select_country($object->country_id,'country_id');
|
||||
print $form->select_country((GETPOST('country_id')!=''?GETPOST('country_id'):$object->country_id),'country_id');
|
||||
if ($user->admin) print info_admin($langs->trans("YouCanChangeValuesForThisListFromDictionnarySetup"),1);
|
||||
print '</td></tr>';
|
||||
|
||||
@ -1548,9 +1549,12 @@ else
|
||||
|
||||
// Country
|
||||
print '<tr><td>'.$langs->trans("Country").'</td><td colspan="'.(2+(($showlogo || $showbarcode)?0:1)).'" class="nowrap">';
|
||||
$img=picto_from_langcode($object->country_code);
|
||||
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
|
||||
else print ($img?$img.' ':'').$object->country;
|
||||
if ($object->country_code)
|
||||
{
|
||||
$img=picto_from_langcode($object->country_code);
|
||||
if ($object->isInEEC()) print $form->textwithpicto(($img?$img.' ':'').$object->country,$langs->trans("CountryIsInEEC"),1,0);
|
||||
else print ($img?$img.' ':'').$object->country;
|
||||
}
|
||||
print '</td></tr>';
|
||||
|
||||
// State
|
||||
|
||||
@ -78,6 +78,8 @@ class AllTests
|
||||
$suite->addTestSuite('FunctionsTest');
|
||||
require_once dirname(__FILE__).'/Functions2Test.php';
|
||||
$suite->addTestSuite('Functions2Test');
|
||||
require_once dirname(__FILE__).'/XCalLibTest.php';
|
||||
$suite->addTestSuite('XCalLibTest');
|
||||
|
||||
require_once dirname(__FILE__).'/SecurityTest.php';
|
||||
$suite->addTestSuite('SecurityTest');
|
||||
|
||||
141
test/phpunit/XCalLibTest.php
Normal file
141
test/phpunit/XCalLibTest.php
Normal file
@ -0,0 +1,141 @@
|
||||
<?php
|
||||
/* Copyright (C) 2010-2012 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
* or see http://www.gnu.org/
|
||||
*/
|
||||
|
||||
/**
|
||||
* \file test/phpunit/XCalLibTest.php
|
||||
* \ingroup test
|
||||
* \brief PHPUnit test
|
||||
* \remarks To run this script as CLI: phpunit filename.php
|
||||
*/
|
||||
|
||||
global $conf,$user,$langs,$db;
|
||||
//define('TEST_DB_FORCE_TYPE','mysql'); // This is to force using mysql driver
|
||||
require_once 'PHPUnit/Autoload.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/master.inc.php';
|
||||
require_once dirname(__FILE__).'/../../htdocs/core/lib/xcal.lib.php';
|
||||
|
||||
if (empty($user->id))
|
||||
{
|
||||
print "Load permissions for admin user nb 1\n";
|
||||
$user->fetch(1);
|
||||
$user->getrights();
|
||||
}
|
||||
$conf->global->MAIN_DISABLE_ALL_MAILS=1;
|
||||
|
||||
|
||||
/**
|
||||
* Class for PHPUnit tests
|
||||
*
|
||||
* @backupGlobals disabled
|
||||
* @backupStaticAttributes enabled
|
||||
* @remarks backupGlobals must be disabled to have db,conf,user and lang not erased.
|
||||
*/
|
||||
class XCalLibTest extends PHPUnit_Framework_TestCase
|
||||
{
|
||||
protected $savconf;
|
||||
protected $savuser;
|
||||
protected $savlangs;
|
||||
protected $savdb;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* We save global variables into local variables
|
||||
*
|
||||
* @return FilesLibTest
|
||||
*/
|
||||
function __construct()
|
||||
{
|
||||
//$this->sharedFixture
|
||||
global $conf,$user,$langs,$db;
|
||||
$this->savconf=$conf;
|
||||
$this->savuser=$user;
|
||||
$this->savlangs=$langs;
|
||||
$this->savdb=$db;
|
||||
|
||||
print __METHOD__." db->type=".$db->type." user->id=".$user->id;
|
||||
//print " - db ".$db->db;
|
||||
print "\n";
|
||||
}
|
||||
|
||||
// Static methods
|
||||
public static function setUpBeforeClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->begin(); // This is to have all actions inside a transaction even if test launched without suite.
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
public static function tearDownAfterClass()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$db->rollback();
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
/**
|
||||
* Init phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function setUp()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
/**
|
||||
* End phpunit tests
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function tearDown()
|
||||
{
|
||||
print __METHOD__."\n";
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* testQuotedPrintEncodeDecode
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testQuotedPrintEncodeDecode()
|
||||
{
|
||||
global $conf,$user,$langs,$db;
|
||||
$conf=$this->savconf;
|
||||
$user=$this->savuser;
|
||||
$langs=$this->savlangs;
|
||||
$db=$this->savdb;
|
||||
|
||||
$stringtoencode='ABCD=1234;';
|
||||
$result=quotedPrintEncode($stringtoencode);
|
||||
print __METHOD__." result=".$result."\n";
|
||||
$this->assertEquals('ABCD=3D1234;',$result);
|
||||
|
||||
$resultback=quotedPrintDecode($result);
|
||||
print __METHOD__." result=".$resultback."\n";
|
||||
$this->assertEquals($stringtoencode,$resultback);
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
Loading…
Reference in New Issue
Block a user