Fix: [ bug #622 ] attaching wrong file when sending the invoice via
This commit is contained in:
parent
567cd00f5c
commit
091e469050
@ -1817,7 +1817,7 @@ if ($action == 'presend')
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
@ -1840,7 +1840,7 @@ if ($action == 'presend')
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->propal->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
|
||||
@ -204,14 +204,14 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
$action='create';
|
||||
$error++;
|
||||
}
|
||||
|
||||
|
||||
if (! $error)
|
||||
{
|
||||
$object->socid=$socid;
|
||||
$object->fetch_thirdparty();
|
||||
|
||||
|
||||
$db->begin();
|
||||
|
||||
|
||||
$object->date_commande = $datecommande;
|
||||
$object->note = GETPOST('note');
|
||||
$object->note_public = GETPOST('note_public');
|
||||
@ -226,7 +226,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
$object->date_livraison = $datelivraison;
|
||||
$object->fk_delivery_address = GETPOST('fk_address');
|
||||
$object->contactid = GETPOST('contactidp');
|
||||
|
||||
|
||||
// If creation from another object of another module (Example: origin=propal, originid=1)
|
||||
if (! empty($origin) && ! empty($originid))
|
||||
{
|
||||
@ -237,7 +237,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
$element = $regs[1];
|
||||
$subelement = $regs[2];
|
||||
}
|
||||
|
||||
|
||||
// For compatibility
|
||||
if ($element == 'order') {
|
||||
$element = $subelement = 'commande';
|
||||
@ -248,10 +248,10 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
if ($element == 'contract') {
|
||||
$element = $subelement = 'contrat';
|
||||
}
|
||||
|
||||
|
||||
$object->origin = $origin;
|
||||
$object->origin_id = $originid;
|
||||
|
||||
|
||||
// Possibility to add external linked objects with hooks
|
||||
$object->linked_objects[$object->origin] = $object->origin_id;
|
||||
$other_linked_objects=GETPOST('other_linked_objects','array');
|
||||
@ -259,32 +259,32 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
{
|
||||
$object->linked_objects = array_merge($object->linked_objects, $other_linked_objects);
|
||||
}
|
||||
|
||||
|
||||
$object_id = $object->create($user);
|
||||
|
||||
|
||||
if ($object_id > 0)
|
||||
{
|
||||
dol_include_once('/'.$element.'/class/'.$subelement.'.class.php');
|
||||
|
||||
|
||||
$classname = ucfirst($subelement);
|
||||
$srcobject = new $classname($db);
|
||||
|
||||
|
||||
dol_syslog("Try to find source object origin=".$object->origin." originid=".$object->origin_id." to add lines");
|
||||
$result=$srcobject->fetch($object->origin_id);
|
||||
if ($result > 0)
|
||||
{
|
||||
$lines = $srcobject->lines;
|
||||
if (empty($lines) && method_exists($srcobject,'fetch_lines')) $lines = $srcobject->fetch_lines();
|
||||
|
||||
|
||||
$fk_parent_line=0;
|
||||
$num=count($lines);
|
||||
|
||||
|
||||
for ($i=0;$i<$num;$i++)
|
||||
{
|
||||
$label=(! empty($lines[$i]->label)?$lines[$i]->label:'');
|
||||
$desc=(! empty($lines[$i]->desc)?$lines[$i]->desc:$lines[$i]->libelle);
|
||||
$product_type=(! empty($lines[$i]->product_type)?$lines[$i]->product_type:0);
|
||||
|
||||
|
||||
// Dates
|
||||
// TODO mutualiser
|
||||
$date_start=$lines[$i]->date_debut_prevue;
|
||||
@ -293,12 +293,12 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
$date_end=$lines[$i]->date_fin_prevue;
|
||||
if ($lines[$i]->date_fin_reel) $date_end=$lines[$i]->date_fin_reel;
|
||||
if ($lines[$i]->date_end) $date_end=$lines[$i]->date_end;
|
||||
|
||||
|
||||
// Reset fk_parent_line for no child products and special product
|
||||
if (($lines[$i]->product_type != 9 && empty($lines[$i]->fk_parent_line)) || $lines[$i]->product_type == 9) {
|
||||
$fk_parent_line = 0;
|
||||
}
|
||||
|
||||
|
||||
$result = $object->addline(
|
||||
$object_id,
|
||||
$desc,
|
||||
@ -323,19 +323,19 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
$lines[$i]->pa_ht,
|
||||
$label
|
||||
);
|
||||
|
||||
|
||||
if ($result < 0)
|
||||
{
|
||||
$error++;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
// Defined the new fk_parent_line
|
||||
if ($result > 0 && $lines[$i]->product_type == 9) {
|
||||
$fk_parent_line = $result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Hooks
|
||||
$parameters=array('objFrom'=>$srcobject);
|
||||
$reshook=$hookmanager->executeHooks('createFrom',$parameters,$object,$action); // Note that $action and $object may have been modified by hook
|
||||
@ -356,7 +356,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
else
|
||||
{
|
||||
$object_id = $object->create($user);
|
||||
|
||||
|
||||
// If some invoice's lines already known
|
||||
$NBLINES=8;
|
||||
for ($i = 1 ; $i <= $NBLINES ; $i++)
|
||||
@ -370,7 +370,7 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Insert default contacts if defined
|
||||
if ($object_id > 0)
|
||||
{
|
||||
@ -383,11 +383,11 @@ else if ($action == 'add' && $user->rights->commande->creer)
|
||||
$error++;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$id = $object_id;
|
||||
$action = '';
|
||||
}
|
||||
|
||||
|
||||
// End of object creation, we show it
|
||||
if ($object_id > 0 && ! $error)
|
||||
{
|
||||
@ -1405,7 +1405,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
$dateinvoice = empty($conf->global->MAIN_AUTOFILL_DATE)?-1:0;
|
||||
|
||||
$datedelivery = (!empty($objectsrc->date_livraison)?$objectsrc->date_livraison:'');
|
||||
|
||||
|
||||
$note_private = (! empty($objectsrc->note) ? $objectsrc->note : (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''));
|
||||
$note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : '');
|
||||
|
||||
@ -2347,7 +2347,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
@ -2370,7 +2370,7 @@ if ($action == 'send' && ! GETPOST('addfile') && ! GETPOST('removedfile') && ! G
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
|
||||
@ -2689,7 +2689,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$num = $db->num_rows($result);
|
||||
$i = 0;
|
||||
|
||||
|
||||
//if ($object->type != 2)
|
||||
//{
|
||||
if ($num > 0)
|
||||
@ -3343,7 +3343,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
@ -3366,7 +3366,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->facture->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
|
||||
@ -140,7 +140,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
||||
if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
|
||||
if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
|
||||
|
||||
if (! $filter || preg_match('/'.$filter.'/i',$path.'/'.$file))
|
||||
if (! $filter || preg_match('/'.$filter.'/i',$file)) // We do not search key $filter into $path, only into $file
|
||||
{
|
||||
$file_list[] = array(
|
||||
"name" => $file,
|
||||
@ -164,7 +164,7 @@ function dol_dir_list($path, $types="all", $recursive=0, $filter="", $excludefil
|
||||
if ($loaddate || $sortcriteria == 'date') $filedate=dol_filemtime($path."/".$file);
|
||||
if ($loadsize || $sortcriteria == 'size') $filesize=dol_filesize($path."/".$file);
|
||||
|
||||
if (! $filter || preg_match('/'.$filter.'/i',$path.'/'.$file))
|
||||
if (! $filter || preg_match('/'.$filter.'/i',$file)) // We do not search key $filter into $path, only into $file
|
||||
{
|
||||
$file_list[] = array(
|
||||
"name" => $file,
|
||||
|
||||
@ -1407,7 +1407,7 @@ else
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
@ -1430,7 +1430,7 @@ else
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->expedition->dir_output . '/sending/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
|
||||
@ -1451,7 +1451,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
@ -1474,7 +1474,7 @@ else if ($id > 0 || ! empty($ref))
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->ficheinter->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
|
||||
@ -1071,7 +1071,7 @@ if (! empty($object->id))
|
||||
if($mysoc->localtax1_assuj=="1") $nbrow++;
|
||||
if($object->thirdparty->localtax2_assuj=="1") $nbrow++;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if($mysoc->localtax1_assuj=="1") $nbrow++;
|
||||
if($mysoc->localtax2_assuj=="1") $nbrow++;
|
||||
@ -1245,7 +1245,7 @@ if (! empty($object->id))
|
||||
print '<td>'.$langs->trans("Currency".$conf->currency).'</td></tr>';
|
||||
}
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
if ($mysoc->localtax1_assuj=="1") //Localtax1
|
||||
{
|
||||
@ -1783,7 +1783,7 @@ if (! empty($object->id))
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
@ -1806,7 +1806,7 @@ if (! empty($object->id))
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref);
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->commande->dir_output . '/' . $ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
|
||||
@ -2036,7 +2036,7 @@ else
|
||||
{
|
||||
$ref = dol_sanitizeFileName($object->ref);
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref);
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
|
||||
// Build document if it not exists
|
||||
@ -2059,7 +2059,7 @@ else
|
||||
dol_print_error($db,$result);
|
||||
exit;
|
||||
}
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref);
|
||||
$fileparams = dol_most_recent_file($conf->fournisseur->facture->dir_output.'/'.get_exdir($object->id,2).$ref, preg_quote($object->ref,'/'));
|
||||
$file=$fileparams['fullname'];
|
||||
}
|
||||
|
||||
|
||||
@ -239,7 +239,10 @@ input:-webkit-autofill {
|
||||
input.liste_titre {
|
||||
box-shadow: none !important;
|
||||
}
|
||||
|
||||
input.removedfile {
|
||||
padding: 0px !important;
|
||||
border: 0px !important;
|
||||
}
|
||||
textarea:disabled {
|
||||
background:#ddd;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user