mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-20 08:21:29 +01:00
Work on BOM templates
This commit is contained in:
@@ -183,16 +183,6 @@ elseif ($action == 'set_BOM_FREE_TEXT')
|
|||||||
{
|
{
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
setEventMessages($langs->trans("Error"), null, 'errors');
|
||||||
}
|
}
|
||||||
} elseif ($action=="setshippableiconinlist") {
|
|
||||||
// Activate Set Shippable Icon In List
|
|
||||||
$setshippableiconinlist = GETPOST('value', 'int');
|
|
||||||
$res = dolibarr_set_const($db, "SHIPPABLE_BOM_ICON_IN_LIST", $setshippableiconinlist, 'yesno', 0, '', $conf->entity);
|
|
||||||
if (! $res > 0) $error++;
|
|
||||||
if (! $error) {
|
|
||||||
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
|
||||||
} else {
|
|
||||||
setEventMessages($langs->trans("Error"), null, 'errors');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -314,8 +304,6 @@ foreach ($dirmodels as $reldir)
|
|||||||
print "</table><br>\n";
|
print "</table><br>\n";
|
||||||
|
|
||||||
|
|
||||||
if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
|
||||||
{
|
|
||||||
/*
|
/*
|
||||||
* Document templates generators
|
* Document templates generators
|
||||||
*/
|
*/
|
||||||
@@ -438,12 +426,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
|||||||
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
$htmltooltip.='<br>'.$langs->trans("Width").'/'.$langs->trans("Height").': '.$module->page_largeur.'/'.$module->page_hauteur;
|
||||||
}
|
}
|
||||||
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
$htmltooltip.='<br><br><u>'.$langs->trans("FeaturesSupported").':</u>';
|
||||||
$htmltooltip.='<br>'.$langs->trans("Logo").': '.yn($module->option_logo, 1, 1);
|
|
||||||
$htmltooltip.='<br>'.$langs->trans("PaymentMode").': '.yn($module->option_modereg, 1, 1);
|
|
||||||
$htmltooltip.='<br>'.$langs->trans("PaymentConditions").': '.yn($module->option_condreg, 1, 1);
|
|
||||||
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
$htmltooltip.='<br>'.$langs->trans("MultiLanguage").': '.yn($module->option_multilang, 1, 1);
|
||||||
//$htmltooltip.='<br>'.$langs->trans("Discounts").': '.yn($module->option_escompte,1,1);
|
|
||||||
//$htmltooltip.='<br>'.$langs->trans("CreditNote").': '.yn($module->option_credit_note,1,1);
|
|
||||||
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
|
$htmltooltip.='<br>'.$langs->trans("WatermarkOnDraftBOMs").': '.yn($module->option_draft_watermark, 1, 1);
|
||||||
|
|
||||||
|
|
||||||
@@ -531,27 +514,7 @@ if ($conf->global->MAIN_FEATURES_LEVEL >= 2)
|
|||||||
|
|
||||||
print '</table>';
|
print '</table>';
|
||||||
print '<br>';
|
print '<br>';
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Notifications
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
print load_fiche_titre($langs->trans("Notifications"), '', '');
|
|
||||||
print '<table class="noborder" width="100%">';
|
|
||||||
print '<tr class="liste_titre">';
|
|
||||||
print '<td>'.$langs->trans("Parameter").'</td>';
|
|
||||||
print '<td class="center" width="60"></td>';
|
|
||||||
print '<td width="80"> </td>';
|
|
||||||
print "</tr>\n";
|
|
||||||
|
|
||||||
print '<tr class="oddeven"><td colspan="2">';
|
|
||||||
print $langs->trans("YouMayFindNotificationsFeaturesIntoModuleNotification").'<br>';
|
|
||||||
print '</td><td class="right">';
|
|
||||||
print "</td></tr>\n";
|
|
||||||
|
|
||||||
print '</table>';
|
|
||||||
*/
|
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
llxFooter();
|
llxFooter();
|
||||||
|
|||||||
@@ -662,14 +662,13 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
print '<a name="builddoc"></a>'; // ancre
|
print '<a name="builddoc"></a>'; // ancre
|
||||||
|
|
||||||
// Documents
|
// Documents
|
||||||
/*$objref = dol_sanitizeFileName($object->ref);
|
$objref = dol_sanitizeFileName($object->ref);
|
||||||
$relativepath = $comref . '/' . $comref . '.pdf';
|
$relativepath = $objref . '/' . $objref . '.pdf';
|
||||||
$filedir = $conf->bom->dir_output . '/' . $objref;
|
$filedir = $conf->bom->dir_output . '/' . $objref;
|
||||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||||
$genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
|
$genallowed = $user->rights->bom->read; // If you can read, you can build the PDF to read content
|
||||||
$delallowed = $user->rights->bom->create; // If you can create/edit, you can remove a file on card
|
$delallowed = $user->rights->bom->write; // If you can create/edit, you can remove a file on card
|
||||||
print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $soc->default_lang);
|
print $formfile->showdocuments('bom', $objref, $filedir, $urlsource, $genallowed, $delallowed, $object->modelpdf, 1, 0, 0, 28, 0, '', '', '', $mysoc->default_lang);
|
||||||
*/
|
|
||||||
|
|
||||||
// Show links to link elements
|
// Show links to link elements
|
||||||
$linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
|
$linktoelem = $form->showLinkToObjectBlock($object, null, array('bom'));
|
||||||
@@ -693,17 +692,15 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Select mail models is same action as presend
|
//Select mail models is same action as presend
|
||||||
/*
|
|
||||||
if (GETPOST('modelselected')) $action = 'presend';
|
if (GETPOST('modelselected')) $action = 'presend';
|
||||||
|
|
||||||
// Presend form
|
// Presend form
|
||||||
$modelmail='inventory';
|
$modelmail='bom';
|
||||||
$defaulttopic='InformationMessage';
|
$defaulttopic='InformationMessage';
|
||||||
$diroutput = $conf->product->dir_output.'/inventory';
|
$diroutput = $conf->bom->dir_output;
|
||||||
$trackid = 'stockinv'.$object->id;
|
$trackid = 'bom'.$object->id;
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// End of page
|
// End of page
|
||||||
|
|||||||
@@ -688,7 +688,7 @@ class FormFile
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dol_print_error($this->db, 'Bad value for modulepart');
|
dol_print_error($this->db, "Bad value for modulepart '".$modulepart."' in showdocuments");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -85,14 +85,7 @@ class doc_generic_bom_odt extends ModelePDFBOMs
|
|||||||
$this->marge_haute=0;
|
$this->marge_haute=0;
|
||||||
$this->marge_basse=0;
|
$this->marge_basse=0;
|
||||||
|
|
||||||
$this->option_logo = 1; // Affiche logo
|
|
||||||
$this->option_tva = 0; // Gere option tva COMMANDE_TVAOPTION
|
|
||||||
$this->option_modereg = 0; // Affiche mode reglement
|
|
||||||
$this->option_condreg = 0; // Affiche conditions reglement
|
|
||||||
$this->option_codeproduitservice = 0; // Affiche code produit-service
|
|
||||||
$this->option_multilang = 1; // Dispo en plusieurs langues
|
$this->option_multilang = 1; // Dispo en plusieurs langues
|
||||||
$this->option_escompte = 0; // Affiche si il y a eu escompte
|
|
||||||
$this->option_credit_note = 0; // Support credit notes
|
|
||||||
$this->option_freetext = 1; // Support add of a personalised text
|
$this->option_freetext = 1; // Support add of a personalised text
|
||||||
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
$this->option_draft_watermark = 0; // Support add of a watermark on drafts
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ require_once DOL_DOCUMENT_ROOT.'/compta/bank/class/account.class.php'; // requir
|
|||||||
/**
|
/**
|
||||||
* Parent class for boms models
|
* Parent class for boms models
|
||||||
*/
|
*/
|
||||||
abstract class ModelePDFBoms extends CommonDocGenerator
|
abstract class ModelePDFBom extends CommonDocGenerator
|
||||||
{
|
{
|
||||||
|
|
||||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ class modBom extends DolibarrModules
|
|||||||
// 1=>array('BILLOFMATERIALS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
|
// 1=>array('BILLOFMATERIALS_MYNEWCONST2','chaine','myvalue','This is another constant to add',0, 'current', 1)
|
||||||
// );
|
// );
|
||||||
$this->const = array(
|
$this->const = array(
|
||||||
1=>array('BOM_ADDON_PDF', 'chaine', 'avalue', 'Name of PDF model of BOM', 0),
|
1=>array('BOM_ADDON_PDF', 'chaine', 'alpha', 'Name of PDF model of BOM', 0),
|
||||||
2=>array('BOM_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0),
|
2=>array('BOM_ADDON', 'chaine', 'mod_bom_standard', 'Name of numbering rules of BOM', 0),
|
||||||
3=>array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0)
|
3=>array('BOM_ADDON_PDF_ODT_PATH', 'chaine', 'DOL_DATA_ROOT/doctemplates/boms', '', 0)
|
||||||
);
|
);
|
||||||
@@ -317,6 +317,8 @@ class modBom extends DolibarrModules
|
|||||||
*/
|
*/
|
||||||
public function init($options = '')
|
public function init($options = '')
|
||||||
{
|
{
|
||||||
|
global $conf, $langs;
|
||||||
|
|
||||||
$result=$this->_load_tables('/bom/sql/');
|
$result=$this->_load_tables('/bom/sql/');
|
||||||
if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')
|
if ($result < 0) return -1; // Do not activate module if not allowed errors found on module SQL queries (the _load_table run sql with run_sql with error allowed parameter to 'default')
|
||||||
|
|
||||||
@@ -330,8 +332,35 @@ class modBom extends DolibarrModules
|
|||||||
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
|
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
|
||||||
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
|
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mrp', '$conf->bom->enabled');
|
||||||
|
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
$this->remove($options);
|
||||||
|
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
|
// ODT template
|
||||||
|
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/boms/template_bom.odt';
|
||||||
|
$dirodt=DOL_DATA_ROOT.'/doctemplates/boms';
|
||||||
|
$dest=$dirodt.'/template_bom.odt';
|
||||||
|
|
||||||
|
if (file_exists($src) && ! file_exists($dest))
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
dol_mkdir($dirodt);
|
||||||
|
$result=dol_copy($src, $dest, 0, 0);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = array(
|
||||||
|
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape('alpha')."' AND type = 'bom' AND entity = ".$conf->entity,
|
||||||
|
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape('alpha')."', 'bom', ".$conf->entity.")"
|
||||||
|
);
|
||||||
|
|
||||||
return $this->_init($sql, $options);
|
return $this->_init($sql, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
BIN
htdocs/install/doctemplates/boms/template_bom.odt
Normal file
BIN
htdocs/install/doctemplates/boms/template_bom.odt
Normal file
Binary file not shown.
@@ -382,6 +382,8 @@ class modMyModule extends DolibarrModules
|
|||||||
*/
|
*/
|
||||||
public function init($options = '')
|
public function init($options = '')
|
||||||
{
|
{
|
||||||
|
global $conf, $langs;
|
||||||
|
|
||||||
$result=$this->_load_tables('/mymodule/sql/');
|
$result=$this->_load_tables('/mymodule/sql/');
|
||||||
if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
|
if ($result < 0) return -1; // Do not activate module if error 'not allowed' returned when loading module SQL queries (the _load_table run sql with run_sql with the error allowed parameter set to 'default')
|
||||||
|
|
||||||
@@ -394,7 +396,36 @@ class modMyModule extends DolibarrModules
|
|||||||
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
|
//$result4=$extrafields->addExtraField('myattr4', "New Attr 4 label", 'select', 1, 3, 'thirdparty', 0, 1, '', array('options'=>array('code1'=>'Val1','code2'=>'Val2','code3'=>'Val3')), 1,'', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
|
||||||
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
|
//$result5=$extrafields->addExtraField('myattr5', "New Attr 5 label", 'text', 1, 10, 'user', 0, 0, '', '', 1, '', 0, 0, '', '', 'mymodule@mymodule', '$conf->mymodule->enabled');
|
||||||
|
|
||||||
|
// Permissions
|
||||||
|
$this->remove($options);
|
||||||
|
|
||||||
$sql = array();
|
$sql = array();
|
||||||
|
|
||||||
|
// ODT template
|
||||||
|
/*
|
||||||
|
$src=DOL_DOCUMENT_ROOT.'/install/doctemplates/mymodule/template_myobjects.odt';
|
||||||
|
$dirodt=DOL_DATA_ROOT.'/doctemplates/mymodule';
|
||||||
|
$dest=$dirodt.'/template_myobjects.odt';
|
||||||
|
|
||||||
|
if (file_exists($src) && ! file_exists($dest))
|
||||||
|
{
|
||||||
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
||||||
|
dol_mkdir($dirodt);
|
||||||
|
$result=dol_copy($src, $dest, 0, 0);
|
||||||
|
if ($result < 0)
|
||||||
|
{
|
||||||
|
$langs->load("errors");
|
||||||
|
$this->error=$langs->trans('ErrorFailToCopyFile', $src, $dest);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$sql = array(
|
||||||
|
"DELETE FROM ".MAIN_DB_PREFIX."document_model WHERE nom = '".$this->db->escape($this->const[0][2])."' AND type = 'mymodule' AND entity = ".$conf->entity,
|
||||||
|
"INSERT INTO ".MAIN_DB_PREFIX."document_model (nom, type, entity) VALUES('".$this->db->escape($this->const[0][2])."','mymodule',".$conf->entity.")"
|
||||||
|
);
|
||||||
|
*/
|
||||||
|
|
||||||
return $this->_init($sql, $options);
|
return $this->_init($sql, $options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -512,7 +512,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
|
|
||||||
// Documents
|
// Documents
|
||||||
/*$objref = dol_sanitizeFileName($object->ref);
|
/*$objref = dol_sanitizeFileName($object->ref);
|
||||||
$relativepath = $comref . '/' . $comref . '.pdf';
|
$relativepath = $objref . '/' . $objref . '.pdf';
|
||||||
$filedir = $conf->mymodule->dir_output . '/' . $objref;
|
$filedir = $conf->mymodule->dir_output . '/' . $objref;
|
||||||
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
$urlsource = $_SERVER["PHP_SELF"] . "?id=" . $object->id;
|
||||||
$genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content
|
$genallowed = $user->rights->mymodule->read; // If you can read, you can build the PDF to read content
|
||||||
@@ -536,7 +536,7 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
// List of actions on element
|
// List of actions on element
|
||||||
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
include_once DOL_DOCUMENT_ROOT . '/core/class/html.formactions.class.php';
|
||||||
$formactions = new FormActions($db);
|
$formactions = new FormActions($db);
|
||||||
$somethingshown = $formactions->showactions($object, 'myobject', $socid, 1, '', $MAXEVENT, '', $morehtmlright);
|
$somethingshown = $formactions->showactions($object, 'myobject', (is_object($object->thirdparty)?$object->thirdparty->id:0), 1, '', $MAXEVENT, '', $morehtmlright);
|
||||||
|
|
||||||
print '</div></div></div>';
|
print '</div></div></div>';
|
||||||
}
|
}
|
||||||
@@ -546,10 +546,10 @@ if ($object->id > 0 && (empty($action) || ($action != 'edit' && $action != 'crea
|
|||||||
if (GETPOST('modelselected')) $action = 'presend';
|
if (GETPOST('modelselected')) $action = 'presend';
|
||||||
|
|
||||||
// Presend form
|
// Presend form
|
||||||
$modelmail='inventory';
|
$modelmail='myobject';
|
||||||
$defaulttopic='InformationMessage';
|
$defaulttopic='InformationMessage';
|
||||||
$diroutput = $conf->product->dir_output.'/inventory';
|
$diroutput = $conf->mymodule->dir_output;
|
||||||
$trackid = 'stockinv'.$object->id;
|
$trackid = 'myobject'.$object->id;
|
||||||
|
|
||||||
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
include DOL_DOCUMENT_ROOT.'/core/tpl/card_presend.tpl.php';
|
||||||
*/
|
*/
|
||||||
|
|||||||
Reference in New Issue
Block a user