83 lines
2.3 KiB
PHP
83 lines
2.3 KiB
PHP
<?php
|
|
|
|
require_once 'include/utils/utils.php';
|
|
|
|
require_once 'includes/Loader.php';
|
|
|
|
vimport ('includes.runtime.EntryPoint');
|
|
|
|
require_once 'SUtiles.php';
|
|
|
|
@session_start();
|
|
|
|
|
|
|
|
$current_user = Users_Record_Model::getCurrentUserModel();
|
|
|
|
$roleid = $current_user->get('roleid');
|
|
|
|
$userId = $current_user->get('id');
|
|
|
|
global $adb;
|
|
|
|
|
|
|
|
|
|
|
|
function getPack($idPack){
|
|
|
|
global $adb;
|
|
|
|
|
|
|
|
$query = "SELECT cf_903 as montant_1 , cf_1097 as remise_sophal_1,
|
|
|
|
cf_909 as montant_2 , cf_1101 as remise_sophal_2,
|
|
|
|
cf_917 as montant_3 , cf_1105 as remise_sophal_3,
|
|
|
|
cf_923 as montant_4 , cf_1109 as remise_sophal_4,
|
|
|
|
cf_929 as montant_5 , cf_1113 as remise_sophal_5,
|
|
|
|
cf_935 as montant_6 , cf_1117 as remise_sophal_6,
|
|
|
|
cf_1067 as montant_7 , cf_1121 as remise_sophal_7
|
|
|
|
|
|
|
|
FROM vtiger_potentialscf WHERE potentialid = {$idPack}";
|
|
|
|
$result =$adb->query($query);
|
|
|
|
|
|
|
|
$res=array();
|
|
|
|
while ($recordinfo = $adb->fetch_array($result)) {
|
|
|
|
$res[] = $recordinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
$temp=array();
|
|
|
|
$Palier = 7 ;
|
|
|
|
for($i = 1 ; $i <= $Palier ; $i++){
|
|
|
|
$montant = $res[0]['montant_'.$i];
|
|
|
|
$remise_sophal = $res[0]['remise_sophal_'.$i];
|
|
|
|
if(($montant != 0 and $montant != null) && ($remise_sophal != 0 and $remise_sophal != null))
|
|
|
|
$temp = $temp + ["{$montant}"=>$remise_sophal];
|
|
|
|
}
|
|
|
|
|
|
|
|
// trier un tableau associatif par ordre decroissant, en fonction de la cle
|
|
|
|
ksort($temp);
|
|
|
|
|
|
|
|
return $temp;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch ($_GET['action']) {
|
|
|
|
//get remise
|
|
|
|
case "getremise":
|
|
|
|
|
|
|
|
$idPack = $_GET['idPack'];
|
|
|
|
$netTotal = $_GET['netTotal'];
|
|
|
|
$remise = 0;
|
|
|
|
|
|
|
|
if(!empty($idPack)){
|
|
|
|
|
|
|
|
$result = getPack($idPack);
|
|
|
|
$keys = array_keys($result);
|
|
|
|
$values = array_values($result);
|
|
|
|
|
|
|
|
for($m = 0 ; $m < count($result) ; $m++){
|
|
|
|
if($keys[$m] <= $netTotal){
|
|
|
|
$remise = $values[$m];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
header('Content-type: application/json');
|
|
|
|
echo json_encode($remise);
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|