|
@@ -75,7 +75,7 @@ if (isset($_GET['propal_assoc'])) {
|
|
|
var_dump($q);
|
|
|
|
|
|
echo '<p>TOTAL : '.mysqli_num_rows($q).'</p>';
|
|
|
- $nbmax = 5000;
|
|
|
+ $nbmax = isset($_GET['nbmax']) && is_numeric($_GET['nbmax']) && $_GET['nbmax']==(int)$_GET['nbmax'] && $_GET['nbmax']>=1000 ?$_GET['nbmax'] :5000;
|
|
|
|
|
|
$ok = 0;
|
|
|
$nb = 0;
|
|
@@ -135,20 +135,40 @@ if (isset($_GET['propal_assoc'])) {
|
|
|
}
|
|
|
// Pas de commercial spécifique => on prend le premier patron
|
|
|
elseif (count($u2) == 0) {
|
|
|
- foreach($u2_save as $userid) {
|
|
|
+ if (isset($_GET['force_boss_assign'])) {
|
|
|
+ foreach($u2_save as $userid) {
|
|
|
+ $sql = 'INSERT INTO `'.DB_D_BASE.'`.`'.DB_D_PREFIX.'element_contact`
|
|
|
+ (datecreate, statut, element_id, fk_c_type_contact, fk_socpeople)
|
|
|
+ VALUES
|
|
|
+ (NOW(), 4, '.$row['p_rowid'].', '.$contact['propal'].', '.$userid.')';
|
|
|
+ pre_sql($sql);
|
|
|
+ if (isset($_GET['go']))
|
|
|
+ DB::d_update($sql);
|
|
|
+ // On prend le permier
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // Afficher choix pour spécification à la main
|
|
|
+ else {
|
|
|
+ // On regarde les commerciaux associés au client
|
|
|
+ if (!empty($row['fk_users'])) {
|
|
|
+ $fk_users = explode(',', $row['fk_users']);
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $fk_users = [];
|
|
|
+ }
|
|
|
+ // Si on a un seul commercial associé au tiers et qu'il est dans la liste des potentiels, on l'assigne
|
|
|
+ if (count($fk_users)==1 && in_array($fk_users[0], $u2_save)) {
|
|
|
+ $userid = $fk_users[0];
|
|
|
$sql = 'INSERT INTO `'.DB_D_BASE.'`.`'.DB_D_PREFIX.'element_contact`
|
|
|
(datecreate, statut, element_id, fk_c_type_contact, fk_socpeople)
|
|
|
VALUES
|
|
|
- (NOW(), 4, '.$row['o_rowid'].', '.$contact['commande'].', '.$userid.')';
|
|
|
+ (NOW(), 4, '.$row['p_rowid'].', '.$contact['propal'].', '.$userid.')';
|
|
|
pre_sql($sql);
|
|
|
if (isset($_GET['go']))
|
|
|
DB::d_update($sql);
|
|
|
- // On prend le permier
|
|
|
- break;
|
|
|
}
|
|
|
- }
|
|
|
- // Afficher choix pour spécification à la main
|
|
|
- else {
|
|
|
foreach($u2_save as $userid) {
|
|
|
echo '<p>Associer => <a href="?t=customer&propal_assoc&map['.$row['p_rowid'].']='.$userid.'">#'.$userid.' - '.$users[$userid]['firstname'].'</a></p>';
|
|
|
}
|