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

This commit is contained in:
Laurent Destailleur 2024-08-01 10:51:25 +02:00
commit 2068f29b44
7 changed files with 65 additions and 27 deletions

View File

@ -258,6 +258,22 @@ class Documents extends DolibarrApi
$templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf;
$result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
throw new RestException(500, 'Error generating document missing doctemplate parameter');
}
} elseif ($modulepart == 'mrp') {
require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php';
$tmpobject = new Mo($this->db);
$result = $tmpobject->fetch(0, preg_replace('/\.[^\.]+$/', '', basename($original_file)));
if (!$result) {
throw new RestException(404, 'MO not found');
}
$templateused = $doctemplate ? $doctemplate : $tmpobject->model_pdf;
$result = $tmpobject->generateDocument($templateused, $outputlangs, $hidedetails, $hidedesc, $hideref);
if ($result <= 0) {
throw new RestException(500, 'Error generating document missing doctemplate parameter');
}
@ -567,6 +583,17 @@ class Documents extends DolibarrApi
}
$upload_dir = $conf->projet->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'project');
} elseif ($modulepart == 'mrp') {
$modulepart = 'mrp';
require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php';
$object = new Mo($this->db);
$result = $object->fetch($id, $ref);
if (!$result) {
throw new RestException(404, 'MO not found');
}
$upload_dir = $conf->mrp->dir_output . "/" . get_exdir(0, 0, 0, 1, $object, 'mrp');
} else {
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');
}
@ -749,6 +776,10 @@ class Documents extends DolibarrApi
$modulepart = 'contrat';
require_once DOL_DOCUMENT_ROOT . '/contrat/class/contrat.class.php';
$object = new Contrat($this->db);
} elseif ($modulepart == 'mrp') {
$modulepart = 'mrp';
require_once DOL_DOCUMENT_ROOT . '/mrp/class/mo.class.php';
$object = new Mo($this->db);
} else {
// TODO Implement additional moduleparts
throw new RestException(500, 'Modulepart '.$modulepart.' not implemented yet.');

View File

@ -600,16 +600,17 @@ class Proposals extends DolibarrApi
* Add a contact type of given commercial proposal
*
* @param int $id Id of commercial proposal to update
* @param int $contactid Id of contact to add
* @param string $type Type of the contact (BILLING, SHIPPING, CUSTOMER)
* @param int $contactid Id of external or internal contact to add
* @param string $type Type of the external contact (BILLING, SHIPPING, CUSTOMER), internal contact (SALESREPFOLL)
* @param string $source Source of the contact (internal, external)
* @return array
*
* @url POST {id}/contact/{contactid}/{type}
* @url POST {id}/contact/{contactid}/{type}/{source}
*
* @throws RestException 401
* @throws RestException 404
*/
public function postContact($id, $contactid, $type)
public function postContact($id, $contactid, $type, $source = 'external')
{
if (!DolibarrApiAccess::$user->hasRight('propal', 'creer')) {
throw new RestException(403);
@ -621,15 +622,23 @@ class Proposals extends DolibarrApi
throw new RestException(404, 'Proposal not found');
}
if (!in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
throw new RestException(500, 'Availables types: BILLING, SHIPPING OR CUSTOMER');
if (!in_array($source, array('internal', 'external'), true)) {
throw new RestException(500, 'Availables sources: internal OR external');
}
if ($source == 'external' && !in_array($type, array('BILLING', 'SHIPPING', 'CUSTOMER'), true)) {
throw new RestException(500, 'Availables external types: BILLING, SHIPPING OR CUSTOMER');
}
if ($source == 'internal' && !in_array($type, array('SALESREPFOLL'), true)) {
throw new RestException(500, 'Availables internal types: SALESREPFOLL');
}
if (!DolibarrApi::_checkAccessToResource('propal', $this->propal->id)) {
throw new RestException(403, 'Access not allowed for login '.DolibarrApiAccess::$user->login);
}
$result = $this->propal->add_contact($contactid, $type, 'external');
$result = $this->propal->add_contact($contactid, $type, $source);
if (!$result) {
throw new RestException(500, 'Error when added the contact');

View File

@ -731,7 +731,7 @@ if ($num > 0) {
}
if ($user->hasRight('cron', 'execute')) {
if (!empty($obj->status)) {
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute';
print '<a class="reposition" href="'.$_SERVER["PHP_SELF"].'?id='.$obj->rowid.'&action=execute&token='.newToken();
print(!getDolGlobalString('CRON_KEY') ? '' : '&securitykey=' . getDolGlobalString('CRON_KEY'));
print($sortfield ? '&sortfield='.$sortfield : '');
print($sortorder ? '&sortorder='.$sortorder : '');

View File

@ -370,15 +370,15 @@ UPDATE llx_mrp_production SET disable_stock_change = 0 WHERE disable_stock_chang
ALTER TABLE llx_socpeople ADD COLUMN url varchar(255);
-- knowledgemanagement module
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CREATE','Knowledgerecord created','Executed when a knowledgerecord is created','knowledgemanagement',57001);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_MODIFY','Knowledgerecord modified','Executed when a knowledgerecord is modified','knowledgemanagement',57002);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_VALIDATE','Knowledgerecord Evaluation validated','Executed when an evaluation is validated','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_REOPEN','Knowledgerecord reopen','Executed when an evaluation is back to draft','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_UNVALIDATE','Knowledgerecord unvalidated','Executed when an evaluation is back to draft','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CANCEL','Knowledgerecord cancel','Executed when an evaluation to cancel','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_SENTBYMAIL','Mails sent from knowledgerecord file','knowledgerecord when you send email from knowledgerecord file','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_DELETE','Knowledgerecord deleted','Executed when a knowledgerecord is deleted','knowledgemanagement',57006);
-- knowledge management module
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CREATE','Knowledge article created','Executed when a article is created','knowledgemanagement',57001);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_MODIFY','Knowledge article modified','Executed when a article is modified','knowledgemanagement',57002);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_VALIDATE','Knowledge article Evaluation validated','Executed when an evaluation is validated','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_REOPEN','Knowledge article reopen','Executed when an evaluation is back to draft','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_UNVALIDATE','Knowledge article invalidated','Executed when an evaluation is back to draft','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_CANCEL','Knowledge article cancel','Executed when an evaluation to cancel','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_SENTBYMAIL','Mails sent from article file','article when you send email from article file','knowledgemanagement',57004);
insert into llx_c_action_trigger (code,label,description,elementtype,rang) values ('KNOWLEDGERECORD_DELETE','Knowledge article deleted','Executed when a article is deleted','knowledgemanagement',57006);
-- table chargesociales indexes
ALTER TABLE llx_chargesociales ADD INDEX idx_chargesociales_fk_type (fk_type);
@ -404,10 +404,10 @@ INSERT INTO llx_c_revenuestamp(rowid,fk_pays,taux,revenuestamp_type,note,active)
ALTER TABLE llx_hrm_evaluation ADD COLUMN entity INTEGER DEFAULT 1 NOT NULL;
-- Erreur SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length
-- Error SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length, so we remove completely the unique key
ALTER TABLE llx_menu DROP INDEX idx_menu_uk_menu;
ALTER TABLE llx_menu MODIFY COLUMN url TEXT NOT NULL;
ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity);
--ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity, url);
UPDATE llx_c_units SET short_label = 'mn' WHERE short_label = 'i' AND code = 'MI';

View File

@ -21,7 +21,5 @@
ALTER TABLE llx_menu ADD INDEX idx_menu_menuhandler_type (menu_handler, type);
-- Erreur SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length
-- ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, url, entity);
ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity);
-- Error SQL DB_ERROR_1170 BLOB/TEXT column 'url' used in key specification without a key length, so we removed completely the unique key
-- ALTER TABLE llx_menu ADD UNIQUE INDEX idx_menu_uk_menu (menu_handler, fk_menu, position, entity, url);

View File

@ -371,7 +371,7 @@ class ProductAttribute extends CommonObject
*
* @param User $user User who updates the attribute
* @param int $notrigger 1 = Do not execute trigger (0 by default)
* @return int <0 if KO, 1 if OK
* @return int Return <0 if KO, 1 if OK
*/
public function update(User $user, $notrigger = 0)
{

View File

@ -118,7 +118,7 @@ class ProductCombination2ValuePair
* Create a ProductCombination2ValuePair
*
* @param User $user User that creates //not used
* @return int<-1,1> 1 if OK, -1 if KO
* @return int Return 1 if OK, -1 if KO
*/
public function create($user)
{
@ -141,7 +141,7 @@ class ProductCombination2ValuePair
* Retrieve all ProductCombination2ValuePair linked to a given ProductCombination ID.
*
* @param int $fk_combination ID of the ProductCombination
* @return -1|ProductCombination2ValuePair[] -1 if KO, array of ProductCombination2ValuePair if OK
* @return -1|ProductCombination2ValuePair[] Return <0 if KO, array of ProductCombination2ValuePair if OK
*/
public function fetchByFkCombination($fk_combination)
{
@ -180,7 +180,7 @@ class ProductCombination2ValuePair
* Delete all ProductCombination2ValuePair linked to a given ProductCombination ID.
*
* @param int $fk_combination ID of the ProductCombination
* @return int<-1|1> -1 if KO, 1 if OK
* @return int Return <0 if KO, 1 if OK
*/
public function deleteByFkCombination($fk_combination)
{