10 |
* Bugs: |
* Bugs: |
11 |
*/ |
*/ |
12 |
|
|
13 |
|
include_once('../obj/messages.class.php'); |
14 |
|
|
15 |
class MessagesManager extends MetierManager { |
class MessagesManager extends MetierManager { |
16 |
|
|
17 |
|
|
18 |
|
var $TYPE_COMPLETUDE_ACC = 'Mise à jour de complétude ERP ACC'; |
19 |
|
var $TYPE_COMPLETUDE_SECU = 'Mise à jour de complétude ERP SECU'; |
20 |
|
|
21 |
/* |
/* |
22 |
* Constructor |
* Constructor |
23 |
* |
* |
25 |
*/ |
*/ |
26 |
public function __construct() { |
public function __construct() { |
27 |
parent::__construct(); |
parent::__construct(); |
28 |
|
$this->table = 'messages'; |
29 |
} |
} |
30 |
|
|
31 |
/* |
/* |
46 |
* @return string 'OK'. |
* @return string 'OK'. |
47 |
*/ |
*/ |
48 |
public function completude_dossier_ACC($data) { |
public function completude_dossier_ACC($data) { |
49 |
|
print $data['type']; |
50 |
|
// check that the type of the message is good |
51 |
|
if ($data['type'] != $this->TYPE_COMPLETUDE_ACC) { |
52 |
|
return $this->BAD_DATA; |
53 |
|
} |
54 |
|
// create the object to hold the data to be stored in DB |
55 |
|
$this->metier_instance = new messages("]", $this->db, 0); |
56 |
|
|
57 |
|
// check that the date is correct |
58 |
|
if (!$this->timestampValid($data['date'], true)) { |
59 |
|
return $this->BAD_DATA; |
60 |
|
} |
61 |
|
|
62 |
|
// check that the contenu contains all elements and prepare the |
63 |
|
// contenu |
64 |
|
$contenu = ''; |
65 |
|
if (!empty($data['contenu']['Complétude ERP ACC']) |
66 |
|
&& !empty($data['contenu']['Motivation Complétude ERP ACC'])) { |
67 |
|
$completude = $data['contenu']['Complétude ERP ACC']; |
68 |
|
if (strtolower($completude) != 'oui' |
69 |
|
&& strtolower($completude) != 'non') { |
70 |
|
return $this->BAD_DATA; |
71 |
|
} |
72 |
|
// replace the contenu |
73 |
|
$contenu .= 'Complétude ERP ACC : '.'\n'. |
74 |
|
'Motivation Complétude ERP ACC : '. |
75 |
|
$data['contenu']['Motivation Complétude ERP ACC']; |
76 |
|
} else { |
77 |
|
return $this->BAD_DATA; |
78 |
|
} |
79 |
|
|
80 |
|
// store info into valF of the messages object, and previously do |
81 |
|
// some data copying so that the array contains the keys searched for |
82 |
|
$data['contenu'] = $contenu; |
83 |
|
$data['dossier'] = $data['dossier_instruction']; |
84 |
|
$data['date_emission'] = $data['date']; // the date |
85 |
|
$data['lu'] = 0; // message unread |
86 |
|
print 'MI type:'.gettype($this->metier_instance); |
87 |
|
$this->metier_instance->setvalF($data); |
88 |
|
|
89 |
|
|
90 |
|
// store the message into DB |
91 |
|
$this->db->autoExecute(DB_PREFIXE.$this->table, $this->valF, DB_AUTOQUERY_INSERT); |
92 |
return $this->OK; |
return $this->OK; |
93 |
} |
} |
94 |
|
|