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

This commit is contained in:
Laurent Destailleur 2011-12-14 10:07:24 +01:00
commit c701eacbce
27 changed files with 746 additions and 573 deletions

View File

@ -22,7 +22,7 @@ PHPExcel 1.7.6 LGPL 2.1 Yes Read/Write XLS files, read ODS files
TCPDF 5.9.098 LGPL 3.0 Yes PDF generation TCPDF 5.9.098 LGPL 3.0 Yes PDF generation
JS libraries: JS libraries:
jQuery 1.6.4 GPL and MIT Licence Yes JS library jQuery 1.7.1 GPL and MIT Licence Yes JS library
jQuery UI 1.8.16 GPL and MIT Licence Yes JS library plugin UI jQuery UI 1.8.16 GPL and MIT Licence Yes JS library plugin UI
jQuery Colorpicker 1.1 MIT Licence Yes JS library for color picker for a defined list of colors jQuery Colorpicker 1.1 MIT Licence Yes JS library for color picker for a defined list of colors
jQuery DataTable 1.8.1 BSD Yes JS library for tables output jQuery DataTable 1.8.1 BSD Yes JS library for tables output

View File

@ -346,11 +346,9 @@ if (function_exists('eaccelerator_get'))
} }
print "<br><br>"; print "<br><br>";
print "<hr />";
print '<table><tr><td class="center">';
print '<strong>Eaccelerator is created by the eAccelerator team, <a href="http://eaccelerator.net">http://eaccelerator.net</a></strong><br><br>';
print "</td></tr></table>";
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -99,13 +99,15 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')
{ {
if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers') ) if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>'; $mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
} }
else else
{ {
$result=$object->createFromClone($id,0,GETPOST('socid'),$hookmanager); if ($object->fetch($id) > 0)
{
$result=$object->createFromClone($socid, $hookmanager);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@ -115,7 +117,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
{ {
$mesg=$object->error; $mesg=$object->error;
$action=''; $action='';
//$_GET['id']=$_REQUEST['id']; }
} }
} }
} }
@ -1568,7 +1570,7 @@ if ($id > 0 || ! empty($ref))
} }
// Send // Send
if ($object->statut == 1) if ($object->statut == 1 || $object->statut == 2)
{ {
$propref = dol_sanitizeFileName($object->ref); $propref = dol_sanitizeFileName($object->ref);
$file = $conf->propale->dir_output . '/'.$propref.'/'.$propref.'.pdf'; $file = $conf->propale->dir_output . '/'.$propref.'/'.$propref.'.pdf';

View File

@ -836,53 +836,45 @@ class Propal extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $fromid Id of object to clone
* @param int $invertdetail Reverse sign of amounts for lines
* @param int $socid Id of thirdparty * @param int $socid Id of thirdparty
* @param HookManager $hookmanager Hook manager instance * @param HookManager $hookmanager Hook manager instance
* @return int New id of clone * @return int New id of clone
*/ */
function createFromClone($fromid,$invertdetail=0,$socid=0,$hookmanager=false) function createFromClone($socid=0,$hookmanager=false)
{ {
global $user,$langs,$conf; global $user,$langs,$conf;
$error=0; $error=0;
$now=dol_now(); $now=dol_now();
$object=new Propal($this->db);
$this->db->begin(); $this->db->begin();
// Load source object // Load source object
$object->fetch($fromid); $objFrom = dol_clone($this);
$objFrom = $object;
$objsoc=new Societe($this->db); $objsoc=new Societe($this->db);
// Change socid if needed // Change socid if needed
if (! empty($socid) && $socid != $object->socid) if (! empty($socid) && $socid != $this->socid)
{ {
if ($objsoc->fetch($socid)>0) if ($objsoc->fetch($socid) > 0)
{ {
$object->socid = $objsoc->id; $this->socid = $objsoc->id;
$object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$object->fk_project = ''; $this->fk_project = '';
$object->fk_delivery_address = ''; $this->fk_delivery_address = '';
} }
// TODO Change product price if multi-prices // TODO Change product price if multi-prices
} }
else else
{ {
$objsoc->fetch($object->socid); $objsoc->fetch($this->socid);
} }
$object->id=0; $this->id=0;
$object->statut=0; $this->statut=0;
$objsoc->fetch($object->socid);
if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php")) if (empty($conf->global->PROPALE_ADDON) || ! is_readable(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"))
{ {
@ -891,28 +883,22 @@ class Propal extends CommonObject
} }
// Clear fields // Clear fields
$object->user_author = $user->id; $this->user_author = $user->id;
$object->user_valid = ''; $this->user_valid = '';
$object->date = ''; $this->date = '';
$object->datep = $now; $this->datep = $now;
$object->fin_validite = $object->datep + ($this->duree_validite * 24 * 3600); $this->fin_validite = $this->datep + ($this->duree_validite * 24 * 3600);
$object->ref_client = ''; $this->ref_client = '';
// Set ref // Set ref
require_once(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php"); require_once(DOL_DOCUMENT_ROOT ."/core/modules/propale/".$conf->global->PROPALE_ADDON.".php");
$obj = $conf->global->PROPALE_ADDON; $obj = $conf->global->PROPALE_ADDON;
$modPropale = new $obj; $modPropale = new $obj;
$object->ref = $modPropale->getNextValue($objsoc,$object); $this->ref = $modPropale->getNextValue($objsoc,$this);
// Create clone // Create clone
$result=$object->create($user); $result=$this->create($user);
if ($result < 0) $error++;
// Other options
if ($result < 0)
{
$this->error=$object->error;
$error++;
}
if (! $error) if (! $error)
{ {
@ -921,14 +907,14 @@ class Propal extends CommonObject
{ {
$parameters=array('objFrom'=>$objFrom); $parameters=array('objFrom'=>$objFrom);
$action=''; $action='';
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++; if ($reshook < 0) $error++;
} }
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('PROPAL_CLONE',$object,$user,$langs,$conf); $result=$interface->run_triggers('PROPAL_CLONE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
} }
@ -937,7 +923,7 @@ class Propal extends CommonObject
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $object->id; return $this->id;
} }
else else
{ {

View File

@ -769,62 +769,51 @@ class Commande extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $fromid Id of object to clone
* @param int $invertdetail Reverse sign of amounts for lines
* @param int $socid Id of thirdparty * @param int $socid Id of thirdparty
* @param HookManager $hookmanager Hook manager instance * @param HookManager $hookmanager Hook manager instance
* @return int New id of clone * @return int New id of clone
*/ */
function createFromClone($fromid,$invertdetail=0,$socid=0,$hookmanager=false) function createFromClone($socid=0,$hookmanager=false)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
$error=0; $error=0;
$object=new Commande($this->db);
$this->db->begin(); $this->db->begin();
// Load source object // Load source object
$object->fetch($fromid); $objFrom = dol_clone($this);
$objFrom = $object;
// Change socid if needed // Change socid if needed
if (! empty($socid) && $socid != $object->socid) if (! empty($socid) && $socid != $this->socid)
{ {
$objsoc = new Societe($this->db); $objsoc = new Societe($this->db);
if ($objsoc->fetch($socid)>0) if ($objsoc->fetch($socid)>0)
{ {
$object->socid = $objsoc->id; $this->socid = $objsoc->id;
$object->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0); $this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$object->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0); $this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$object->fk_project = ''; $this->fk_project = '';
$object->fk_delivery_address = ''; $this->fk_delivery_address = '';
} }
// TODO Change product price if multi-prices // TODO Change product price if multi-prices
} }
$object->id=0; $this->id=0;
$object->statut=0; $this->statut=0;
// Clear fields // Clear fields
$object->user_author_id = $user->id; $this->user_author_id = $user->id;
$object->user_valid = ''; $this->user_valid = '';
$object->date_creation = ''; $this->date_creation = '';
$object->date_validation = ''; $this->date_validation = '';
$object->ref_client = ''; $this->ref_client = '';
// Create clone // Create clone
$result=$object->create($user); $result=$this->create($user);
if ($result < 0) $error++;
// Other options
if ($result < 0)
{
$this->error=$object->error;
$error++;
}
if (! $error) if (! $error)
{ {
@ -833,14 +822,14 @@ class Commande extends CommonObject
{ {
$parameters=array('objFrom'=>$objFrom); $parameters=array('objFrom'=>$objFrom);
$action=''; $action='';
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++; if ($reshook < 0) $error++;
} }
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('ORDER_CLONE',$object,$user,$langs,$conf); $result=$interface->run_triggers('ORDER_CLONE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
} }
@ -849,7 +838,7 @@ class Commande extends CommonObject
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $object->id; return $this->id;
} }
else else
{ {

View File

@ -79,13 +79,15 @@ $reshook=$hookmanager->executeHooks('doActions',$parameters,$object,$action);
// Action clone object // Action clone object
if ($action == 'confirm_clone' && $confirm == 'yes') if ($action == 'confirm_clone' && $confirm == 'yes')
{ {
if ( 1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers') ) if (1==0 && ! GETPOST('clone_content') && ! GETPOST('clone_receivers'))
{ {
$mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>'; $mesg='<div class="error">'.$langs->trans("NoCloneOptionsSpecified").'</div>';
} }
else else
{ {
$result=$object->createFromClone($id, 0, GETPOST('socid'), $hookmanager); if ($object->fetch($id) > 0)
{
$result=$object->createFromClone($socid, $hookmanager);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?id='.$result);
@ -97,6 +99,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
$action=''; $action='';
} }
} }
}
} }
// Reopen a closed order // Reopen a closed order

View File

@ -228,7 +228,7 @@ print '<td align="center" valign="top">';
print '<table class="border" width="100%"><tr valign="top"><td align="center">'; print '<table class="border" width="100%"><tr valign="top"><td align="center">';
if ($mesg) { print $mesg; } if ($mesg) { print $mesg; }
else { else {
print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfOrders").'" alt="'.$langs->trans("NbOfProposals").'">'; print '<img src="'.$fileurlnb.'" title="'.$langs->trans("NbOfOrders").'" alt="'.$langs->trans("NbOfOrders").'">';
print "<br>\n"; print "<br>\n";
print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">'; print '<img src="'.$fileurlamount.'" title="'.$langs->trans("AmountTotal").'" alt="'.$langs->trans("AmountTotal").'">';
} }

View File

@ -98,7 +98,9 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
} }
else else
{ {
$result=$object->createFromClone($id,0,$hookmanager); if ($object->fetch($id) > 0)
{
$result=$object->createFromClone($socid, $hookmanager);
if ($result > 0) if ($result > 0)
{ {
header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result); header("Location: ".$_SERVER['PHP_SELF'].'?facid='.$result);
@ -110,6 +112,7 @@ if ($action == 'confirm_clone' && $confirm == 'yes')
$action=''; $action='';
} }
} }
}
} }
// Change status of invoice // Change status of invoice

View File

@ -490,60 +490,65 @@ class Facture extends CommonObject
/** /**
* Load an object from its id and create a new one in database * Load an object from its id and create a new one in database
* *
* @param int $fromid Id of object to clone * @param int $socid Id of thirdparty
* @param int $invertdetail Reverse sign of amounts for lines
* @param HookManager $hookmanager Hook manager instance * @param HookManager $hookmanager Hook manager instance
* @return int New id of clone * @return int New id of clone
*/ */
function createFromClone($fromid,$invertdetail=0,$hookmanager=false) function createFromClone($socid=0,$hookmanager=false)
{ {
global $conf,$user,$langs; global $conf,$user,$langs;
$error=0; $error=0;
// Load source object
$objFrom=new Facture($this->db);
$objFrom->fetch($fromid);
// Load new object
$object=new Facture($this->db);
$object->fetch($fromid);
$this->db->begin(); $this->db->begin();
$object->id=0; // Load source object
$object->statut=0; $objFrom = dol_clone($this);
// Change socid if needed
if (! empty($socid) && $socid != $this->socid)
{
$objsoc = new Societe($this->db);
if ($objsoc->fetch($socid)>0)
{
$this->socid = $objsoc->id;
$this->cond_reglement_id = (! empty($objsoc->cond_reglement_id) ? $objsoc->cond_reglement_id : 0);
$this->mode_reglement_id = (! empty($objsoc->mode_reglement_id) ? $objsoc->mode_reglement_id : 0);
$this->fk_project = '';
$this->fk_delivery_address = '';
}
// TODO Change product price if multi-prices
}
$this->id=0;
$this->statut=0;
// Clear fields // Clear fields
$object->user_author = $user->id; $this->user_author = $user->id;
$object->user_valid = ''; $this->user_valid = '';
$object->fk_facture_source = 0; $this->fk_facture_source = 0;
$object->date_creation = ''; $this->date_creation = '';
$object->date_validation = ''; $this->date_validation = '';
$object->ref_client = ''; $this->ref_client = '';
$object->close_code = ''; $this->close_code = '';
$object->close_note = ''; $this->close_note = '';
$object->products = $object->lines; // Tant que products encore utilise $this->products = $this->lines; // Tant que products encore utilise
// Loop on each line of new invoice // Loop on each line of new invoice
foreach($object->lines as $i => $line) foreach($this->lines as $i => $line)
{ {
if (($object->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts if (($this->lines[$i]->info_bits & 0x02) == 0x02) // We do not clone line of discounts
{ {
unset($object->lines[$i]); unset($this->lines[$i]);
unset($object->products[$i]); // Tant que products encore utilise unset($this->products[$i]); // Tant que products encore utilise
} }
} }
// Create clone // Create clone
$result=$object->create($user); $result=$this->create($user);
if ($result < 0) $error++;
// Other options
if ($result < 0)
{
$this->error=$object->error;
$error++;
}
if (! $error) if (! $error)
{ {
@ -552,14 +557,14 @@ class Facture extends CommonObject
{ {
$parameters=array('objFrom'=>$objFrom); $parameters=array('objFrom'=>$objFrom);
$action=''; $action='';
$reshook=$hookmanager->executeHooks('createfrom',$parameters,$object,$action); // Note that $action and $object may have been modified by some hooks $reshook=$hookmanager->executeHooks('createfrom',$parameters,$this,$action); // Note that $action and $object may have been modified by some hooks
if ($reshook < 0) $error++; if ($reshook < 0) $error++;
} }
// Appel des triggers // Appel des triggers
include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php"); include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
$interface=new Interfaces($this->db); $interface=new Interfaces($this->db);
$result=$interface->run_triggers('BILL_CLONE',$object,$user,$langs,$conf); $result=$interface->run_triggers('BILL_CLONE',$this,$user,$langs,$conf);
if ($result < 0) { $error++; $this->errors=$interface->errors; } if ($result < 0) { $error++; $this->errors=$interface->errors; }
// Fin appel triggers // Fin appel triggers
} }
@ -568,7 +573,7 @@ class Facture extends CommonObject
if (! $error) if (! $error)
{ {
$this->db->commit(); $this->db->commit();
return $object->id; return $this->id;
} }
else else
{ {

View File

@ -25,10 +25,12 @@
require("../../main.inc.php"); require("../../main.inc.php");
require_once(DOL_DOCUMENT_ROOT."/core/modules/rapport/pdf_paiement.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/modules/rapport/pdf_paiement.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
// Security check // Security check
if (! $user->rights->facture->lire) if (! $user->rights->facture->lire) accessforbidden();
accessforbidden();
$action=GETPOST('action');
$dir = $conf->facture->dir_output.'/payments'; $dir = $conf->facture->dir_output.'/payments';
@ -48,7 +50,7 @@ if (! $year) { $year=date("Y"); }
* Actions * Actions
*/ */
if ($_POST["action"] == 'builddoc') if ($action == 'builddoc')
{ {
$rap = new pdf_paiement($db); $rap = new pdf_paiement($db);
@ -80,6 +82,8 @@ if ($_POST["action"] == 'builddoc')
* View * View
*/ */
$formother=new FormOther($db);
llxHeader(); llxHeader();
$titre=($year?$langs->trans("PaymentsReportsForYear",$year):$langs->trans("PaymentsReports")); $titre=($year?$langs->trans("PaymentsReportsForYear",$year):$langs->trans("PaymentsReports"));
@ -92,33 +96,10 @@ print '<input type="hidden" name="action" value="builddoc">';
$cmonth = GETPOST("remonth")?GETPOST("remonth"):date("n", time()); $cmonth = GETPOST("remonth")?GETPOST("remonth"):date("n", time());
$syear = GETPOST("reyear")?GETPOST("reyear"):date("Y", time()); $syear = GETPOST("reyear")?GETPOST("reyear"):date("Y", time());
print '<select class="flat" name="remonth">'; print $formother->select_month($cmonth,'remonth');
for ($month = 1 ; $month < 13 ; $month++)
{ print $formother->select_year($syear,'reyear');
if ($month == $cmonth)
{
print "<option value=\"$month\" selected=\"true\">" . dol_print_date(mktime(0,0,0,$month),"%B");
}
else
{
print "<option value=\"$month\">" . dol_print_date(mktime(0,0,0,$month),"%B");
}
}
print "</select>";
print '<select class="flat" name="reyear">';
for ($formyear = $syear - 2; $formyear < $syear +1 ; $formyear++)
{
if ($formyear == $syear)
{
print "<option value=\"$formyear\" selected=\"true\">".$formyear."</option>";
}
else
{
print "<option value=\"$formyear\">".$formyear."</option>";
}
}
print "</select>\n";
print '<input type="submit" class="button" value="'.$langs->trans("Create").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Create").'">';
print '</form>'; print '</form>';
print '<br>'; print '<br>';
@ -183,7 +164,8 @@ if ($year)
print '</table>'; print '</table>';
} }
} }
$db->close();
llxFooter(); llxFooter();
$db->close();
?> ?>

View File

@ -159,7 +159,6 @@ class Translate {
{ {
global $conf; global $conf;
//var_dump($this->dir);exit;
// Check parameters // Check parameters
if (empty($domain)) if (empty($domain))
{ {
@ -266,9 +265,6 @@ class Translate {
} }
else else
{ {
// On stocke toujours dans le tableau Tab en UTF-8
//if (! empty($this->charset_inputfile[$newdomain]) && $this->charset_inputfile[$newdomain] == 'ISO-8859-1') $value=utf8_encode($value);
$this->tab_translate[$key]=$value; $this->tab_translate[$key]=$value;
if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache if ($usecachekey) $tabtranslatedomain[$key]=$value; // To save lang content in cache
} }
@ -289,7 +285,6 @@ class Translate {
dol_syslog($error, LOG_ERR); dol_syslog($error, LOG_ERR);
} }
} }
//exit;
if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop. if (empty($conf->global->MAIN_FORCELANGDIR)) break; // Break loop on each root dir. If a module has forced dir, we do not stop loop.
} }
@ -389,6 +384,8 @@ class Translate {
*/ */
function trans($key, $param1='', $param2='', $param3='', $param4='', $maxsize=0) function trans($key, $param1='', $param2='', $param3='', $param4='', $maxsize=0)
{ {
global $conf;
if (! empty($this->tab_translate[$key])) // Translation is available if (! empty($this->tab_translate[$key])) // Translation is available
{ {
$str=$this->tab_translate[$key]; $str=$this->tab_translate[$key];
@ -400,14 +397,23 @@ class Translate {
// We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities // We replace some HTML tags by __xx__ to avoid having them encoded by htmlentities
$str=str_replace(array('<','>','"',),array('__lt__','__gt__','__quot__'),$str); $str=str_replace(array('<','>','"',),array('__lt__','__gt__','__quot__'),$str);
//$str=$this->convToOutputCharset($str); // Convert string to $this->charset_output
// Crypt string into HTML // Crypt string into HTML
// $str est une chaine stockee en memoire au format $this->charset_output
$str=htmlentities($str,ENT_QUOTES,$this->charset_output); $str=htmlentities($str,ENT_QUOTES,$this->charset_output);
// Restore HTML tags // Restore HTML tags
$str=str_replace(array('__lt__','__gt__','__quot__'),array('<','>','"',),$str); $str=str_replace(array('__lt__','__gt__','__quot__'),array('<','>','"',),$str);
// Overwrite translation
if (! empty($conf->global->MAIN_OVERWRITE_TRANS)) // Overwrite translation with string1:newstring1,string2:newstring2
{
$tmparray=explode(',', $conf->global->MAIN_OVERWRITE_TRANS);
foreach($tmparray as $tmp)
{
$tmparray2=explode(':',$tmp);
if ($tmparray2[0]==$str) { $str=$tmparray2[1]; break; }
}
}
return $str; return $str;
} }
else // Translation is not available else // Translation is not available
@ -458,7 +464,7 @@ class Translate {
{ {
$str=$this->tab_translate[$key]; $str=$this->tab_translate[$key];
$str=sprintf($str,$param1,$param2,$param3,$param4); if (! preg_match('/^Format/',$key)) $str=sprintf($str,$param1,$param2,$param3,$param4); // Replace %s and %d except for FormatXXX strings.
} }
else else
{ {

View File

@ -542,6 +542,7 @@ class DoliDBMssql
/** /**
* Escape a string to insert data. * Escape a string to insert data.
*
* @param stringtoencode String to escape * @param stringtoencode String to escape
* @return string String escaped * @return string String escaped
*/ */
@ -554,18 +555,20 @@ class DoliDBMssql
/** /**
* Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field. * Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica * Function to use to build INSERT, UPDATE or WHERE predica
* @param param Date TMS to convert *
* @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS * @return string Date in a string YYYYMMDDHHMMSS
*/ */
function idate($param) function idate($param)
{ {
return adodb_strftime("%Y-%m-%d %H:%M:%S",$param); return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
} }
/** /**
* Convert (by PHP) a PHP server TZ string date into a GM Timestamps date * Convert (by PHP) a PHP server TZ string date into a GM Timestamps date
* 19700101020000 -> 3600 with TZ+1 * 19700101020000 -> 3600 with TZ+1
* @param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) *
* @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @return date Date TMS * @return date Date TMS
*/ */
function jdate($string) function jdate($string)

View File

@ -537,19 +537,19 @@ class DoliDBMysql
* Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field. * Convert (by PHP) a GM Timestamp date into a string date with PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica * Function to use to build INSERT, UPDATE or WHERE predica
* *
* @param param Date TMS to convert * @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS * @return string Date in a string YYYYMMDDHHMMSS
*/ */
function idate($param) function idate($param)
{ {
return adodb_strftime("%Y%m%d%H%M%S",$param); return dol_print_date($param,"%Y%m%d%H%M%S");
} }
/** /**
* Convert (by PHP) a PHP server TZ string date into a GM Timestamps date * Convert (by PHP) a PHP server TZ string date into a GM Timestamps date
* 19700101020000 -> 3600 with TZ+1 * 19700101020000 -> 3600 with TZ+1
* *
* @param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @return date Date TMS * @return date Date TMS
*/ */
function jdate($string) function jdate($string)

View File

@ -549,19 +549,19 @@ class DoliDBMysqli
* Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field. * Convert (by PHP) a GM Timestamp date into a PHP server TZ to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica * Function to use to build INSERT, UPDATE or WHERE predica
* *
* @param param Date TMS to convert * @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS * @return string Date in a string YYYYMMDDHHMMSS
*/ */
function idate($param) function idate($param)
{ {
return adodb_strftime("%Y%m%d%H%M%S",$param); return dol_print_date($param,"%Y%m%d%H%M%S");
} }
/** /**
* Convert (by PHP) a PHP server TZ string date into a GM Timestamps date * Convert (by PHP) a PHP server TZ string date into a GM Timestamps date
* 19700101020000 -> 3600 with TZ+1 * 19700101020000 -> 3600 with TZ+1
* *
* @param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @return date Date TMS * @return date Date TMS
*/ */
function jdate($string) function jdate($string)

View File

@ -693,19 +693,19 @@ class DoliDBPgsql
* Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field. * Convert (by PHP) a GM Timestamp date into a GM string date to insert into a date field.
* Function to use to build INSERT, UPDATE or WHERE predica * Function to use to build INSERT, UPDATE or WHERE predica
* *
* @param param Date TMS to convert * @param string $param Date TMS to convert
* @return string Date in a string YYYYMMDDHHMMSS * @return string Date in a string YYYYMMDDHHMMSS
*/ */
function idate($param) function idate($param)
{ {
return adodb_strftime("%Y-%m-%d %H:%M:%S",$param); return dol_print_date($param,"%Y-%m-%d %H:%M:%S");
} }
/** /**
* Convert (by PHP) a PHP server TZ string date into a GM Timestamps date * Convert (by PHP) a PHP server TZ string date into a GM Timestamps date
* 19700101020000 -> 3600 with TZ+1 * 19700101020000 -> 3600 with TZ+1
* *
* @param string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS) * @param string $string Date in a string (YYYYMMDDHHMMSS, YYYYMMDD, YYYY-MM-DD HH:MM:SS)
* @return date Date TMS * @return date Date TMS
*/ */
function jdate($string) function jdate($string)

View File

@ -856,19 +856,40 @@ function complete_dictionnary_with_modules(&$taborder,&$tabname,&$tablib,&$tabsq
$orders = array(); $orders = array();
$categ = array(); $categ = array();
$dirmod = array(); $dirmod = array();
$modulesdir = array();
$i = 0; // is a sequencer of modules found $i = 0; // is a sequencer of modules found
$j = 0; // j is module number. Automatically affected if module number not defined. $j = 0; // j is module number. Automatically affected if module number not defined.
foreach ($conf->file->dol_document_root as $dirroot)
{
$dir = $dirroot . "/core/modules/";
foreach ($conf->file->dol_document_root as $type => $dirroot)
{
$modulesdir[$dirroot . '/core/modules/'] = $dirroot . '/core/modules/';
$handle=@opendir($dirroot);
if (is_resource($handle))
{
while (($file = readdir($handle))!==false)
{
if (is_dir($dirroot.'/'.$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && $file != 'includes')
{
if (is_dir($dirroot . '/' . $file . '/core/modules/'))
{
$modulesdir[$dirroot . '/' . $file . '/core/modules/'] = $dirroot . '/' . $file . '/core/modules/';
}
}
}
closedir($handle);
}
}
//var_dump($modulesdir);
foreach ($modulesdir as $dir)
{
// Load modules attributes in arrays (name, numero, orders) from dir directory // Load modules attributes in arrays (name, numero, orders) from dir directory
//print $dir."\n<br>"; //print $dir."\n<br>";
dol_syslog("Scan directory ".$dir." for modules"); dol_syslog("Scan directory ".$dir." for modules");
$handle=@opendir(dol_osencode($dir)); $handle=@opendir(dol_osencode($dir));
if (is_resource($handle)) if (is_resource($handle))
{ {
while (($file = readdir($handle))!==false) while (($file = readdir($handle))!==false)
{ {
//print "$i ".$file."\n<br>"; //print "$i ".$file."\n<br>";

View File

@ -804,13 +804,13 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e
$to_gmt=false; $to_gmt=false;
$offsettz=$offsetdst=0; $offsettz=$offsetdst=0;
} }
if ($tzoutput == 'tzuser') elseif ($tzoutput == 'tzuser')
{ {
$to_gmt=true; $to_gmt=true;
$offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60; $offsettz=(empty($_SESSION['dol_tz'])?0:$_SESSION['dol_tz'])*60*60;
$offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60; $offsetdst=(empty($_SESSION['dol_dst'])?0:$_SESSION['dol_dst'])*60*60;
} }
if ($tzoutput == 'tzcompany') elseif ($tzoutput == 'tzcompany')
{ {
$to_gmt=false; $to_gmt=false;
$offsettz=$offsetdst=0; // TODO Define this and use it later $offsettz=$offsetdst=0; // TODO Define this and use it later

View File

@ -132,7 +132,8 @@ function member_admin_prepare_head($object)
/** /**
* Return array head with list of tabs to view object stats informations * Return array head with list of tabs to view object stats informations
* @param object Member *
* @param Object $object Member or null
* @return array head * @return array head
*/ */
function member_stats_prepare_head($object) function member_stats_prepare_head($object)

View File

@ -159,10 +159,10 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid')
$hideunselectables = false; $hideunselectables = false;
if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true; if (! empty($conf->global->PROJECT_HIDE_UNSELECTABLES)) $hideunselectables = true;
$projectstatic=new Project($db); $projectsListId = false;
$projectsListId = '';
if (empty($user->rights->projet->all->lire)) if (empty($user->rights->projet->all->lire))
{ {
$projectstatic=new Project($db);
$projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1); $projectsListId = $projectstatic->getProjectsAuthorizedForUser($user,0,1);
} }
@ -170,13 +170,10 @@ function select_projects($socid=-1, $selected='', $htmlname='projectid')
$sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public'; $sql = 'SELECT p.rowid, p.ref, p.title, p.fk_soc, p.fk_statut, p.public';
$sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p'; $sql.= ' FROM '.MAIN_DB_PREFIX .'projet as p';
$sql.= " WHERE p.entity = ".$conf->entity; $sql.= " WHERE p.entity = ".$conf->entity;
if ($projectsListId) $sql.= " AND p.rowid in (".$projectsListId.")"; if ($projectsListId) $sql.= " AND p.rowid IN (".$projectsListId.")";
if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)"; if ($socid == 0) $sql.= " AND (p.fk_soc=0 OR p.fk_soc IS NULL)";
//if ($socid > 0) $sql.= " AND (p.fk_soc=".$socid." OR p.fk_soc='0' OR p.fk_soc IS NULL)"; // We will filter later
$sql.= " ORDER BY p.title ASC"; $sql.= " ORDER BY p.title ASC";
//print $sql;
//var_dump($user->rights);
dol_syslog("project.lib::select_projects sql=".$sql); dol_syslog("project.lib::select_projects sql=".$sql);
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)

View File

@ -461,9 +461,9 @@ class FactureFournisseur extends Facture
if (isset($this->tva)) $this->tva=trim($this->tva); if (isset($this->tva)) $this->tva=trim($this->tva);
if (isset($this->localtax1)) $this->localtax1=trim($this->localtax1); if (isset($this->localtax1)) $this->localtax1=trim($this->localtax1);
if (isset($this->localtax2)) $this->localtax2=trim($this->localtax2); if (isset($this->localtax2)) $this->localtax2=trim($this->localtax2);
if (isset($this->total)) $this->total=trim($this->total); if (empty($this->total)) $this->total=0;
if (isset($this->total_ht)) $this->total_ht=trim($this->total_ht); if (empty($this->total_ht)) $this->total_ht=0;
if (isset($this->total_tva)) $this->total_tva=trim($this->total_tva); if (empty($this->total_tva)) $this->total_tva=0;
// if (isset($this->total_localtax1)) $this->total_localtax1=trim($this->total_localtax1); // if (isset($this->total_localtax1)) $this->total_localtax1=trim($this->total_localtax1);
// if (isset($this->total_localtax2)) $this->total_localtax2=trim($this->total_localtax2); // if (isset($this->total_localtax2)) $this->total_localtax2=trim($this->total_localtax2);
if (isset($this->total_ttc)) $this->total_ttc=trim($this->total_ttc); if (isset($this->total_ttc)) $this->total_ttc=trim($this->total_ttc);

View File

@ -1,22 +1,22 @@
<?php <?php
/* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2003-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com> * Copyright (C) 2005 Marc Barilley / Ocebo <marc@ocebo.com>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/fourn/facture/document.php * \file htdocs/fourn/facture/document.php
@ -35,7 +35,7 @@ $langs->load('bills');
$langs->load('other'); $langs->load('other');
$langs->load("companies"); $langs->load("companies");
$facid = isset($_GET["facid"])?$_GET["facid"]:''; $facid = GETPOST("facid")?GETPOST("facid"):GETPOST("id");
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; $action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action'];
// Security check // Security check
@ -46,13 +46,16 @@ $result = restrictedArea($user, 'fournisseur', $facid, 'facture_fourn', 'facture
$sortfield = GETPOST("sortfield",'alpha'); $sortfield = GETPOST("sortfield",'alpha');
$sortorder = GETPOST("sortorder",'alpha'); $sortorder = GETPOST("sortorder",'alpha');
$page = GETPOST("page",'int'); $page = GETPOST("page",'int');
if ($page == -1) { $page = 0; } if ($page == -1) {
$page = 0;
}
$offset = $conf->liste_limit * $page; $offset = $conf->liste_limit * $page;
$pageprev = $page - 1; $pageprev = $page - 1;
$pagenext = $page + 1; $pagenext = $page + 1;
if (! $sortorder) $sortorder="ASC"; if (! $sortorder) $sortorder="ASC";
if (! $sortfield) $sortfield="name"; if (! $sortfield) $sortfield="name";
$object = new FactureFournisseur($db);
/* /*
@ -114,9 +117,18 @@ if ($action=='delete')
} }
} }
// Set label
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
{
$object->fetch($facid);
$object->label=$_POST['label'];
$result=$object->update($user);
if ($result < 0) dol_print_error($db);
}
/* /*
* Affichage * View
*/ */
$form = new Form($db); $form = new Form($db);
@ -125,15 +137,14 @@ llxHeader();
if ($facid > 0) if ($facid > 0)
{ {
$facture = new FactureFournisseur($db); if ($object->fetch($facid))
if ($facture->fetch($facid))
{ {
$facture->fetch_thirdparty(); $object->fetch_thirdparty();
$ref=dol_sanitizeFileName($facture->ref); $ref=dol_sanitizeFileName($object->ref);
$upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($facture->id,2).$ref; $upload_dir = $conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref;
$head = facturefourn_prepare_head($facture); $head = facturefourn_prepare_head($object);
dol_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), 0, 'bill'); dol_fiche_head($head, 'documents', $langs->trans('SupplierInvoice'), 0, 'bill');
@ -150,17 +161,62 @@ if ($facid > 0)
// Ref // Ref
print '<tr><td width="30%" nowrap="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td width="30%" nowrap="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($facture,'facid','',1,'rowid','ref',$morehtmlref); print $form->showrefnav($object,'facid','',1,'rowid','ref',$morehtmlref);
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Ref supplier // Ref supplier
print '<tr><td nowrap="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$facture->ref_supplier.'</td>'; print '<tr><td nowrap="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$object->ref_supplier.'</td>';
print "</tr>\n"; print "</tr>\n";
// Societe // Thirdparty
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$facture->thirdparty->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
// Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">';
print $object->getLibType();
if ($object->type == 1)
{
$facreplaced=new FactureFournisseur($db);
$facreplaced->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
}
if ($object->type == 2)
{
$facusing=new FactureFournisseur($db);
$facusing->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
}
$facidavoir=$object->getListIdAvoirFromInvoice();
if (count($facidavoir) > 0)
{
print ' ('.$langs->transnoentities("InvoiceHasAvoir");
$i=0;
foreach($facidavoir as $id)
{
if ($i==0) print ' ';
else print ',';
$facavoir=new FactureFournisseur($db);
$facavoir->fetch($id);
print $facavoir->getNomUrl(1);
}
print ')';
}
if ($facidnext > 0)
{
$facthatreplace=new FactureFournisseur($db);
$facthatreplace->fetch($facidnext);
print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
}
print '</td></tr>';
// Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td colspan="3">';
print $form->editfieldval("Label",'label',$object->label,$object,0);
print '</td>';
// Nb of files
print '<tr><td>'.$langs->trans('NbOfAttachedFiles').'</td><td colspan="3">'.count($filearray).'</td></tr>'; print '<tr><td>'.$langs->trans('NbOfAttachedFiles').'</td><td colspan="3">'.count($filearray).'</td></tr>';
print '<tr><td>'.$langs->trans('TotalSizeOfAttachedFiles').'</td><td colspan="3">'.$totalsize.' '.$langs->trans('bytes').'</td></tr>'; print '<tr><td>'.$langs->trans('TotalSizeOfAttachedFiles').'</td><td colspan="3">'.$totalsize.' '.$langs->trans('bytes').'</td></tr>';
@ -168,17 +224,18 @@ if ($facid > 0)
print '</table>'; print '</table>';
print '</div>'; print '</div>';
if ($mesg) { print $mesg.'<br>'; }
dol_htmloutput_mesg($mesg);
// Affiche formulaire upload // Affiche formulaire upload
$formfile=new FormFile($db); $formfile=new FormFile($db);
$formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$facture->id,'',0,0,$user->rights->fournisseur->facture->creer); $formfile->form_attach_new_file(DOL_URL_ROOT.'/fourn/facture/document.php?facid='.$object->id,'',0,0,$user->rights->fournisseur->facture->creer);
// List of document // List of document
$param='&facid='.$facture->id; $param='&facid='.$object->id;
$formfile->list_of_documents($filearray,$facture,'facture_fournisseur',$param,0,get_exdir($facture->id,2,0).$facture->id.'/'); $formfile->list_of_documents($filearray,$object,'facture_fournisseur',$param,0,get_exdir($object->id,2,0).$object->id.'/');
} }
else else

View File

@ -149,7 +149,7 @@ if (($action == 'setref_supplier' || $action == 'set_ref_supplier') && $user->ri
$result=$object->set_ref_supplier($user, $_POST['ref_supplier']); $result=$object->set_ref_supplier($user, $_POST['ref_supplier']);
} }
// Set supplier ref // Set label
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer) if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
{ {
$object->fetch($id); $object->fetch($id);
@ -217,9 +217,8 @@ if ($action == 'update' && ! $_POST['cancel'])
$result = $db->query($sql); $result = $db->query($sql);
} }
} }
/*
* Action creation // Create
*/
if ($action == 'add' && $user->rights->fournisseur->facture->creer) if ($action == 'add' && $user->rights->fournisseur->facture->creer)
{ {
$error=0; $error=0;
@ -640,9 +639,7 @@ if ($action == 'reopen' && $user->rights->fournisseur->facture->creer)
} }
} }
/* // Add file in email form
* Add file in email form
*/
if ($_POST['addfile']) if ($_POST['addfile'])
{ {
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@ -656,9 +653,7 @@ if ($_POST['addfile'])
$action='presend'; $action='presend';
} }
/* // Remove file in email form
* Remove file in email form
*/
if (! empty($_POST['removedfile'])) if (! empty($_POST['removedfile']))
{ {
require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/files.lib.php");
@ -672,9 +667,7 @@ if (! empty($_POST['removedfile']))
$action='presend'; $action='presend';
} }
/* // Send mail
* Send mail
*/
if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel']) if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_POST['cancel'])
{ {
$langs->load('mails'); $langs->load('mails');
@ -830,10 +823,7 @@ if ($action == 'send' && ! $_POST['addfile'] && ! $_POST['removedfile'] && ! $_P
//$action = 'presend'; //$action = 'presend';
} }
/* // Build document
* Build document
*/
if ($action == 'builddoc') if ($action == 'builddoc')
{ {
// Save modele used // Save modele used
@ -879,7 +869,7 @@ if ($action == 'remove_file')
/* /*
* View * View
*/ */
$form = new Form($db); $form = new Form($db);
$formfile = new FormFile($db); $formfile = new FormFile($db);
@ -1312,7 +1302,6 @@ else
} }
print '</td></tr>'; print '</td></tr>';
// Label // Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="3">'; print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)).'</td><td colspan="3">';
print $form->editfieldval("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer)); print $form->editfieldval("Label",'label',$object->label,$object,($object->statut<2 && $user->rights->fournisseur->facture->creer));

View File

@ -29,17 +29,17 @@ require_once(DOL_DOCUMENT_ROOT."/fourn/class/fournisseur.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/html.formother.class.php");
require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/date.lib.php");
if (!$user->rights->fournisseur->facture->lire) if (!$user->rights->fournisseur->facture->lire) accessforbidden();
accessforbidden();
$langs->load("companies"); $langs->load("companies");
$langs->load("bills"); $langs->load("bills");
$socid = $_GET["socid"]; $socid = GETPOST("socid");
// Security check // Security check
if ($user->societe_id > 0) if ($user->societe_id > 0)
{ {
$action='';
$_GET["action"] = ''; $_GET["action"] = '';
$socid = $user->societe_id; $socid = $user->societe_id;
} }
@ -47,9 +47,9 @@ if ($user->societe_id > 0)
$mode=GETPOST("mode"); $mode=GETPOST("mode");
$modesearch=GETPOST("mode_search"); $modesearch=GETPOST("mode_search");
$page=$_GET["page"]; $page=GETPOST("page");
$sortorder = $_GET["sortorder"]; $sortorder = GETPOST("sortorder");
$sortfield = $_GET["sortfield"]; $sortfield = GETPOST("sortfield");
if ($page == -1) { $page = 0 ; } if ($page == -1) { $page = 0 ; }
$limit = $conf->liste_limit; $limit = $conf->liste_limit;
@ -59,8 +59,8 @@ $pagenext = $page + 1;
if (! $sortorder) $sortorder="DESC"; if (! $sortorder) $sortorder="DESC";
if (! $sortfield) $sortfield="fac.datef"; if (! $sortfield) $sortfield="fac.datef";
$month =$_GET['month']; $month = GETPOST('month','int');
$year =$_GET['year']; $year = GETPOST('year','int');
/* /*
@ -122,13 +122,13 @@ if ($_GET["filtre"])
} }
} }
if ($_REQUEST["search_ref"]) if (GETPOST("search_ref"))
{ {
$sql .= " AND fac.rowid like '%".$db->escape($_REQUEST["search_ref"])."%'"; $sql .= " AND fac.rowid like '%".$db->escape(GETPOST("search_ref"))."%'";
} }
if ($_REQUEST["search_ref_supplier"]) if (GETPOST("search_ref_supplier"))
{ {
$sql .= " AND fac.facnumber like '%".$db->escape($_REQUEST["search_ref_supplier"])."%'"; $sql .= " AND fac.facnumber like '%".$db->escape(GETPOST("search_ref_supplier"))."%'";
} }
if ($month > 0) if ($month > 0)
{ {
@ -141,24 +141,24 @@ else if ($year > 0)
{ {
$sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'"; $sql.= " AND fac.datef BETWEEN '".$db->idate(dol_get_first_day($year,1,false))."' AND '".$db->idate(dol_get_last_day($year,12,false))."'";
} }
if ($_GET["search_libelle"]) if (GETPOST("search_libelle"))
{ {
$sql .= " AND fac.libelle like '%".$db->escape($_GET["search_libelle"])."%'"; $sql .= " AND fac.libelle like '%".$db->escape(GETPOST("search_libelle"))."%'";
} }
if ($_GET["search_societe"]) if (GETPOST("search_societe"))
{ {
$sql .= " AND s.nom like '%".$db->escape($_GET["search_societe"])."%'"; $sql .= " AND s.nom like '%".$db->escape(GETPOST("search_societe"))."%'";
} }
if ($_GET["search_montant_ht"]) if (GETPOST("search_montant_ht"))
{ {
$sql .= " AND fac.total_ht = '".$db->escape($_GET["search_montant_ht"])."'"; $sql .= " AND fac.total_ht = '".$db->escape(GETPOST("search_montant_ht"))."'";
} }
if ($_GET["search_montant_ttc"]) if (GETPOST("search_montant_ttc"))
{ {
$sql .= " AND fac.total_ttc = '".$db->escape($_GET["search_montant_ttc"])."'"; $sql .= " AND fac.total_ttc = '".$db->escape(GETPOST("search_montant_ttc"))."'";
} }
$sql.= $db->order($sortfield,$sortorder); $sql.= $db->order($sortfield,$sortorder);
@ -175,11 +175,15 @@ if ($resql)
$soc->fetch($socid); $soc->fetch($socid);
} }
$param='&amp;socid='.$socid; $param='&amp;socid='.$socid;
if ($month) $param.='&amp;month='.$month; if ($month) $param.='&amp;month='.urlencode($month);
if ($year) $param.='&amp;year=' .$year; if ($year) $param.='&amp;year=' .urlencode($year);
if (GETPOST("search_ref")) $param.='&amp;search_ref='.urlencode(GETPOST("search_ref"));
if (GETPOST("search_ref_supplier")) $param.='&amp;search_ref_supplier'.urlencode(GETPOST("search_ref_supplier"));
if (GETPOST("search_libelle")) $param.='&amp;search_libelle='.urlencode(GETPOST("search_libelle"));
if (GETPOST("search_societe")) $param.='&amp;search_societe='.urlencode(GETPOST("search_societe"));
if (GETPOST("search_montant_ht")) $param.='&amp;search_montant_ht='.urlencode(GETPOST("search_montant_ht"));
if (GETPOST("search_montant_ttc")) $param.='&amp;search_montant_ttc='.urlencode(GETPOST("search_montant_ttc"));
print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php",$param,$sortfield,$sortorder,'',$num); print_barre_liste($langs->trans("BillsSuppliers").($socid?" $soc->nom":""),$page,"index.php",$param,$sortfield,$sortorder,'',$num);
print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="GET" action="'.$_SERVER["PHP_SELF"].'">';
@ -200,10 +204,10 @@ if ($resql)
print '<tr class="liste_titre">'; print '<tr class="liste_titre">';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref" value="'.$_REQUEST["search_ref"].'">'; print '<input class="flat" size="6" type="text" name="search_ref" value="'.GETPOST("search_ref").'">';
print '</td>'; print '</td>';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.$_REQUEST["search_ref_supplier"].'">'; print '<input class="flat" size="6" type="text" name="search_ref_supplier" value="'.GETPOST("search_ref_supplier").'">';
print '</td>'; print '</td>';
print '<td class="liste_titre" colspan="1" align="center">'; print '<td class="liste_titre" colspan="1" align="center">';
print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">'; print '<input class="flat" type="text" size="1" maxlength="2" name="month" value="'.$month.'">';
@ -214,14 +218,14 @@ if ($resql)
print '</td>'; print '</td>';
print '<td class="liste_titre">&nbsp;</td>'; print '<td class="liste_titre">&nbsp;</td>';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" size="16" type="text" name="search_libelle" value="'.$_GET["search_libelle"].'">'; print '<input class="flat" size="16" type="text" name="search_libelle" value="'.GETPOST("search_libelle").'">';
print '</td>'; print '</td>';
print '<td class="liste_titre" align="left">'; print '<td class="liste_titre" align="left">';
print '<input class="flat" type="text" size="8" name="search_societe" value="'.$_GET["search_societe"].'">'; print '<input class="flat" type="text" size="8" name="search_societe" value="'.GETPOST("search_societe").'">';
print '</td><td class="liste_titre" align="right">'; print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="8" name="search_montant_ht" value="'.$_GET["search_montant_ht"].'">'; print '<input class="flat" type="text" size="8" name="search_montant_ht" value="'.GETPOST("search_montant_ht").'">';
print '</td><td class="liste_titre" align="right">'; print '</td><td class="liste_titre" align="right">';
print '<input class="flat" type="text" size="8" name="search_montant_ttc" value="'.$_GET["search_montant_ttc"].'">'; print '<input class="flat" type="text" size="8" name="search_montant_ttc" value="'.GETPOST("search_montant_ttc").'">';
print '</td><td class="liste_titre" colspan="2" align="center">'; print '</td><td class="liste_titre" colspan="2" align="center">';
print '<input type="image" class="liste_titre" align="right" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">'; print '<input type="image" class="liste_titre" align="right" name="button_search" src="'.DOL_URL_ROOT.'/theme/'.$conf->theme.'/img/search.png" value="'.dol_escape_htmltag($langs->trans("Search")).'" title="'.dol_escape_htmltag($langs->trans("Search")).'">';
print '</td>'; print '</td>';
@ -238,16 +242,16 @@ if ($resql)
$obj = $db->fetch_object($resql); $obj = $db->fetch_object($resql);
$var=!$var; $var=!$var;
print "<tr $bc[$var]>"; print "<tr ".$bc[$var].">";
print '<td nowrap>'; print '<td nowrap="nowrap">';
$facturestatic->id=$obj->facid; $facturestatic->id=$obj->facid;
$facturestatic->ref=$obj->ref; $facturestatic->ref=$obj->ref;
$facturestatic->ref_supplier=$obj->facnumber; $facturestatic->ref_supplier=$obj->facnumber;
print $facturestatic->getNomUrl(1); print $facturestatic->getNomUrl(1);
print "</td>\n"; print "</td>\n";
print '<td nowrap>'.dol_trunc($obj->facnumber,10)."</td>"; print '<td nowrap="nowrap">'.dol_trunc($obj->facnumber,10)."</td>";
print '<td align="center" nowrap="1">'.dol_print_date($db->jdate($obj->datef),'day').'</td>'; print '<td align="center" nowrap="nowrap">'.dol_print_date($db->jdate($obj->datef),'day').'</td>';
print '<td align="center" nowrap="1">'.dol_print_date($db->jdate($obj->date_echeance),'day'); print '<td align="center" nowrap="nowrap">'.dol_print_date($db->jdate($obj->date_echeance),'day');
if (($obj->paye == 0) && ($obj->fk_statut > 0) && $db->jdate($obj->date_echeance) < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning"); if (($obj->paye == 0) && ($obj->fk_statut > 0) && $db->jdate($obj->date_echeance) < ($now - $conf->facture->fournisseur->warning_delay)) print img_picto($langs->trans("Late"),"warning");
print '</td>'; print '</td>';
print '<td>'.dol_trunc($obj->libelle,36).'</td>'; print '<td>'.dol_trunc($obj->libelle,36).'</td>';

View File

@ -1,21 +1,21 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2009 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2009 Regis Houssin <regis@dolibarr.fr>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or * the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version. * (at your option) any later version.
* *
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
/** /**
* \file htdocs/fourn/facture/note.php * \file htdocs/fourn/facture/note.php
@ -31,29 +31,30 @@ require_once(DOL_DOCUMENT_ROOT.'/fourn/class/fournisseur.facture.class.php');
$langs->load('bills'); $langs->load('bills');
$langs->load("companies"); $langs->load("companies");
$facid = isset($_GET["facid"])?$_GET["facid"]:''; $facid = GETPOST("facid")?GETPOST("facid"):GETPOST('id');
$action=empty($_GET['action']) ? (empty($_POST['action']) ? '' : $_POST['action']) : $_GET['action']; $action = GETPOST('action');
// Security check // Security check
if ($user->societe_id) $socid=$user->societe_id; if ($user->societe_id) $socid=$user->societe_id;
$result = restrictedArea($user, 'fournisseur', $facid, 'facture_fourn', 'facture'); $result = restrictedArea($user, 'fournisseur', $facid, 'facture_fourn', 'facture');
$fac = new FactureFournisseur($db); $object = new FactureFournisseur($db);
$fac->fetch($_GET["facid"]); $object->fetch($facid);
/******************************************************************************/ /******************************************************************************/
/* Actions */ /* Actions */
/******************************************************************************/ /******************************************************************************/
if ($_POST["action"] == 'update_public' && $user->rights->facture->creer) if ($action == 'update_public' && $user->rights->facture->creer)
{ {
$db->begin(); $db->begin();
$res=$fac->update_note_public($_POST["note_public"],$user); $res=$object->update_note_public($_POST["note_public"],$user);
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$fac->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
$db->rollback(); $db->rollback();
} }
else else
@ -62,14 +63,14 @@ if ($_POST["action"] == 'update_public' && $user->rights->facture->creer)
} }
} }
if ($_POST["action"] == 'update' && $user->rights->fournisseur->facture->creer) if ($action == 'update' && $user->rights->fournisseur->facture->creer)
{ {
$db->begin(); $db->begin();
$res=$fac->update_note($_POST["note"],$user); $res=$object->update_note($_POST["note"],$user);
if ($res < 0) if ($res < 0)
{ {
$mesg='<div class="error">'.$fac->error.'</div>'; $mesg='<div class="error">'.$object->error.'</div>';
$db->rollback(); $db->rollback();
} }
else else
@ -78,21 +79,29 @@ if ($_POST["action"] == 'update' && $user->rights->fournisseur->facture->creer)
} }
} }
// Set label
if ($action == 'setlabel' && $user->rights->fournisseur->facture->creer)
{
$object->fetch($facid);
$object->label=$_POST['label'];
$result=$object->update($user);
if ($result < 0) dol_print_error($db);
}
/* /*
* View * View
*/ */
$form = new Form($db); $form = new Form($db);
llxHeader(); llxHeader();
if ($_GET["facid"]) if ($facid)
{ {
$fac->fetch_thirdparty(); $object->fetch_thirdparty();
$head = facturefourn_prepare_head($fac); $head = facturefourn_prepare_head($object);
$titre=$langs->trans('SupplierInvoice'); $titre=$langs->trans('SupplierInvoice');
dol_fiche_head($head, 'note', $titre, 0, 'bill'); dol_fiche_head($head, 'note', $titre, 0, 'bill');
@ -101,32 +110,76 @@ if ($_GET["facid"])
// Ref // Ref
print '<tr><td width="20%" nowrap="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">'; print '<tr><td width="20%" nowrap="nowrap">'.$langs->trans("Ref").'</td><td colspan="3">';
print $form->showrefnav($fac,'facid','',1,'rowid','ref',$morehtmlref); print $form->showrefnav($object,'facid','',1,'rowid','ref',$morehtmlref);
print '</td>'; print '</td>';
print "</tr>\n"; print "</tr>\n";
// Ref supplier // Ref supplier
print '<tr><td nowrap="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$fac->ref_supplier.'</td>'; print '<tr><td nowrap="nowrap">'.$langs->trans("RefSupplier").'</td><td colspan="3">'.$object->ref_supplier.'</td>';
print "</tr>\n"; print "</tr>\n";
// Company // Company
print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$fac->thirdparty->getNomUrl(1).'</td></tr>'; print '<tr><td>'.$langs->trans('Supplier').'</td><td colspan="3">'.$object->thirdparty->getNomUrl(1).'</td></tr>';
// Note publique // Type
print '<tr><td>'.$langs->trans('Type').'</td><td colspan="4">';
print $object->getLibType();
if ($object->type == 1)
{
$facreplaced=new FactureFournisseur($db);
$facreplaced->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("ReplaceInvoice",$facreplaced->getNomUrl(1)).')';
}
if ($object->type == 2)
{
$facusing=new FactureFournisseur($db);
$facusing->fetch($object->fk_facture_source);
print ' ('.$langs->transnoentities("CorrectInvoice",$facusing->getNomUrl(1)).')';
}
$facidavoir=$object->getListIdAvoirFromInvoice();
if (count($facidavoir) > 0)
{
print ' ('.$langs->transnoentities("InvoiceHasAvoir");
$i=0;
foreach($facidavoir as $id)
{
if ($i==0) print ' ';
else print ',';
$facavoir=new FactureFournisseur($db);
$facavoir->fetch($id);
print $facavoir->getNomUrl(1);
}
print ')';
}
if ($facidnext > 0)
{
$facthatreplace=new FactureFournisseur($db);
$facthatreplace->fetch($facidnext);
print ' ('.$langs->transnoentities("ReplacedByInvoice",$facthatreplace->getNomUrl(1)).')';
}
print '</td></tr>';
// Label
print '<tr><td>'.$form->editfieldkey("Label",'label',$object->label,$object,0).'</td><td colspan="3">';
print $form->editfieldval("Label",'label',$object->label,$object,0);
print '</td>';
// Note public
print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>'; print '<tr><td valign="top">'.$langs->trans("NotePublic").' :</td>';
print '<td valign="top" colspan="3">'; print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit') if ($_GET["action"] == 'edit')
{ {
print '<form method="post" action="note.php?facid='.$fac->id.'">'; print '<form method="post" action="note.php?facid='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update_public">'; print '<input type="hidden" name="action" value="update_public">';
print '<textarea name="note_public" cols="80" rows="8">'.$fac->note_public."</textarea><br>"; print '<textarea name="note_public" cols="80" rows="8">'.$object->note_public."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>'; print '</form>';
} }
else else
{ {
print ($fac->note_public?nl2br($fac->note_public):"&nbsp;"); print ($object->note_public?nl2br($object->note_public):"&nbsp;");
} }
print "</td></tr>"; print "</td></tr>";
@ -137,16 +190,16 @@ if ($_GET["facid"])
print '<td valign="top" colspan="3">'; print '<td valign="top" colspan="3">';
if ($_GET["action"] == 'edit') if ($_GET["action"] == 'edit')
{ {
print '<form method="post" action="note.php?facid='.$fac->id.'">'; print '<form method="post" action="note.php?facid='.$object->id.'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="update">'; print '<input type="hidden" name="action" value="update">';
print '<textarea name="note" cols="80" rows="8">'.$fac->note."</textarea><br>"; print '<textarea name="note" cols="80" rows="8">'.$object->note."</textarea><br>";
print '<input type="submit" class="button" value="'.$langs->trans("Save").'">'; print '<input type="submit" class="button" value="'.$langs->trans("Save").'">';
print '</form>'; print '</form>';
} }
else else
{ {
print ($fac->note?nl2br($fac->note):"&nbsp;"); print ($object->note?nl2br($object->note):"&nbsp;");
} }
print "</td></tr>"; print "</td></tr>";
} }
@ -156,13 +209,13 @@ if ($_GET["facid"])
dol_fiche_end(); dol_fiche_end();
/* /*
* Actions * Buttons
*/ */
print '<div class="tabsAction">'; print '<div class="tabsAction">';
if ($user->rights->fournisseur->facture->creer && $_GET["action"] <> 'edit') if ($user->rights->fournisseur->facture->creer && $_GET["action"] <> 'edit')
{ {
print "<a class=\"butAction\" href=\"note.php?facid=$fac->id&amp;action=edit\">".$langs->trans('Modify')."</a>"; print "<a class=\"butAction\" href=\"note.php?facid=$object->id&amp;action=edit\">".$langs->trans('Modify')."</a>";
} }
print "</div>"; print "</div>";

File diff suppressed because one or more lines are too long

View File

@ -146,5 +146,79 @@ class DateLibTest extends PHPUnit_Framework_TestCase
return $result; return $result;
} }
/**
*/
public function testDolPrintDate()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
// Check %Y-%m-%d %H:%M:%S format
$result=dol_print_date(0,'%Y-%m-%d %H:%M:%S',true);
print __METHOD__." result=".$result."\n";
$this->assertEquals('1970-01-01 00:00:00',$result);
// Check dayhour format for fr_FR
$outputlangs=new Translate('',$conf);
$outputlangs->setDefaultLang('fr_FR');
$outputlangs->load("main");
$result=dol_print_date(0+24*3600,'dayhour',true,$outputlangs);
print __METHOD__." result=".$result."\n";
$this->assertEquals('02/01/1970 00:00',$result);
// Check day format for en_US
$outputlangs=new Translate('',$conf);
$outputlangs->setDefaultLang('en_US');
$outputlangs->load("main");
$result=dol_print_date(0+24*3600,'day',true,$outputlangs);
print __METHOD__." result=".$result."\n";
$this->assertEquals('01/02/1970',$result);
// Check %a and %b format for en_US
$result=dol_print_date(0,'%a %b',true,$outputlangs);
print __METHOD__." result=".$result."\n";
$this->assertEquals('Thu jan',$result);
return $result;
}
/**
*/
public function testDolTimePlusDuree()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
// Check dayhour format for fr_FR
$outputlangs=new Translate('',$conf);
$outputlangs->setDefaultLang('fr_FR');
$outputlangs->load("main");
$result=dol_print_date(dol_time_plus_duree(dol_time_plus_duree(dol_time_plus_duree(0,1,'m'),1,'y'),1,'d'),'dayhour',true,$outputlangs);
print __METHOD__." result=".$result."\n";
$this->assertEquals('02/02/1971 00:00',$result);
return $result;
}
/**
*/
public function testDolGetFirstDay()
{
global $conf,$user,$langs,$db;
$conf=$this->savconf;
$user=$this->savuser;
$langs=$this->savlangs;
$db=$this->savdb;
}
} }
?> ?>