diff --git a/apps/maarch_entreprise/admin/users/users_management_controler.php b/apps/maarch_entreprise/admin/users/users_management_controler.php
index 4e1fe9952e5c08a1cf52e81c0bf7c1c392426ab4..76ba6b01b1974ba82381a840b9a51b72ba81f2cf 100644
--- a/apps/maarch_entreprise/admin/users/users_management_controler.php
+++ b/apps/maarch_entreprise/admin/users/users_management_controler.php
@@ -663,9 +663,25 @@ function display_up_check($user_id)
                     $visa->setStatusVisa($res_id, 'letterbox_coll');
 
                     //UDPATE listinstance to reset previous visa user
-                    $query = "UPDATE listinstance SET process_comment = null, process_date = null WHERE listinstance_id = (SELECT listinstance_id FROM listinstance WHERE res_id = ? AND item_mode = 'visa' AND difflist_type = 'VISA_CIRCUIT' order by sequence DESC LIMIT 1)";
+                    // $query = "UPDATE listinstance SET process_comment = null, process_date = null WHERE listinstance_id = (SELECT listinstance_id FROM listinstance WHERE res_id = ? AND item_mode = 'visa' AND difflist_type = 'VISA_CIRCUIT' order by sequence DESC LIMIT 1)";
+                    // $arrayPDO = array($res_id);
+                    // $db->query($query, $arrayPDO);
+                    
+                    $whereSub = "res_id = ? AND item_mode = 'visa' AND difflist_type = 'VISA_CIRCUIT'";
+                    $orderSub = "ORDER BY sequence DESC";
+                    $subQuery = $db->limit_select(0, 1, 'listinstance_id', 'listinstance', $whereSub, '', '', $orderSub);
+                    //echo $subQuery . '<br/>';
                     $arrayPDO = array($res_id);
-                    $db->query($query, $arrayPDO);  
+                    $stmt = $db->query($subQuery, $arrayPDO);
+                    while ($resSub = $stmt->fetchObject()) {
+                        $listinstanceIDs[] = $resSub->listinstance_id;
+                    }
+                    if (count($listinstanceIDs) > 0) {
+                        //var_dump($listinstanceIDs);
+                        $query = "UPDATE listinstance SET process_comment = null, process_date = null WHERE listinstance_id in (?)";
+                        $db->query($query, $listinstanceIDs);
+                        //echo $query . '<br/>';
+                    }
 
                 }
 
diff --git a/apps/maarch_entreprise/class/class_chrono_Abstract.php b/apps/maarch_entreprise/class/class_chrono_Abstract.php
index 599b75bcd0536d4bdb79d16881567fe9274f3bbb..6e7a049de6547ac566024dbf2db4f376fb9eae9a 100755
--- a/apps/maarch_entreprise/class/class_chrono_Abstract.php
+++ b/apps/maarch_entreprise/class/class_chrono_Abstract.php
@@ -228,11 +228,11 @@ abstract class chrono_Abstract
     {
         $db = new Database();
         //Get res_id of document
-        if($res_id==''){
-            $stmt = $db->query(
-                "SELECT res_id FROM res_letterbox ORDER BY res_id DESC LIMIT 1"
-            );
-        }else{
+        if ($res_id=='') {
+            $order = "ORDER by res_id DESC";
+            $query = $db->limit_select(0, 1, 'res_id', 'res_letterbox', '', '', '', $order);
+            $stmt = $db->query($query);
+        } else {
             $stmt = $db->query(
                 "SELECT res_id FROM res_letterbox WHERE res_id=?",
                 array($res_id)
diff --git a/apps/maarch_entreprise/indexing_searching/contact_check.php b/apps/maarch_entreprise/indexing_searching/contact_check.php
index 007b06cb85761de517e6958a8af5f190e1ded94b..5d03876e3d0a858743f757d386623a0ca02cde25 100644
--- a/apps/maarch_entreprise/indexing_searching/contact_check.php
+++ b/apps/maarch_entreprise/indexing_searching/contact_check.php
@@ -67,7 +67,7 @@ if(empty($_POST['contact_id']) || $_POST['category'] == 'outgoing'){
 		$_SESSION['excludeId'] = $_POST['res_id'];
 	}
 
-	$order = " ORDER by creation_date DESC";
+	$order = "ORDER by creation_date DESC";
 	$query = $db->limit_select(0, 1, 'res_id', 'res_view_letterbox', $wherePDO, '', '', $order);
 
 	$stmt = $db->query($query, $arrayPDO);
diff --git a/apps/maarch_entreprise/my_contacts/get_last_contact_address.php b/apps/maarch_entreprise/my_contacts/get_last_contact_address.php
index 4935e25a7a73aa8e2aec4c6407089d64a4959db7..792391adf83b1fcc101b4c3eed3a6d2cae28c6eb 100644
--- a/apps/maarch_entreprise/my_contacts/get_last_contact_address.php
+++ b/apps/maarch_entreprise/my_contacts/get_last_contact_address.php
@@ -28,7 +28,7 @@
 * @ingroup admin
 */
 
-require_once 'core' . DIRECTORY_SEPARATOR . 'class' . DIRECTORY_SEPARATOR . 'class_request.php';
+require_once 'core/class/class_request.php';
 $db = new Database();
 
 if (isset($_GET['mode']) && $_GET['mode'] == 'up') {
@@ -37,13 +37,34 @@ if (isset($_GET['mode']) && $_GET['mode'] == 'up') {
 } else if (isset($_GET['contactid']) && $_GET['contactid'] <> '' && isset($_GET['addressid']) && $_GET['addressid'] <> ''){
 	$extra = ' AND contact_id = ? and ca_id = ? ';
 	$arrayPDO = array($_GET['contactid'], $_GET['addressid']);
-} 
-else {
-	$extra = ' ORDER BY ca_id DESC limit 1';
+} else {
+	$orderBy = "ORDER BY ca_id DESC";
 	$arrayPDO = array();
+	$specific = true;
 }
 
-$stmt = $db->query("SELECT is_corporate_person, 
+if ($specific) {
+	$select = "is_corporate_person, 
+					contact_lastname, 
+					contact_firstname, 
+					society, 
+					society_short, 
+					contact_id, 
+					ca_id, 
+					lastname,
+					firstname,
+					address_num,
+					address_street,
+					address_town,
+					address_postal_code,
+					creation_date,
+					contact_purpose_label,
+					departement,
+					update_date";
+    $query = $db->limit_select(0, 1, $select, 'view_contacts', '', '', '', $orderBy);
+    $stmt = $db->query($query);
+} else {
+	$stmt = $db->query("SELECT is_corporate_person, 
 					contact_lastname, 
 					contact_firstname, 
 					society, 
@@ -62,6 +83,9 @@ $stmt = $db->query("SELECT is_corporate_person,
 					update_date 
 			FROM view_contacts 
 			WHERE 1=1 " . $extra, $arrayPDO);
+}
+
+
 // $stmt->DebugDumpParams();
 $res = $stmt->fetchObject();
 
diff --git a/apps/maarch_entreprise/services/Table.php b/apps/maarch_entreprise/services/Table.php
index 9d283f8c8ee25f5bf8a2083c8c4001674281d2cf..336e42919e5de3c1d7949c7f753d180393d7a2fc 100644
--- a/apps/maarch_entreprise/services/Table.php
+++ b/apps/maarch_entreprise/services/Table.php
@@ -167,14 +167,22 @@ class Apps_Table_Service extends Core_Abstract_Service {
             }
             $limit = ' LIMIT '.$args['limit'];
         }
-        // Query :
-        $queryExt = "SELECT $select FROM $tablename $where $group_by $order_by $limit";
-        //Core_Logs_Service::debug(['message'=>'Requête:'.$queryExt]); 
-        //echo "the query " . $queryExt . PHP_EOL;var_export($data). PHP_EOL;
+
         if(!isset($GLOBALS['configFile'])){
             $GLOBALS['configFile'] = null;
         }
         $db = new Database($GLOBALS['configFile']);
+        
+        // Query :
+        if ($limit <> '') {
+            $queryExt = $db->limit_select(0, $limit, $select, $tablename, $where, $group_by, '', $order_by);
+        } else {
+            $queryExt = "SELECT $select FROM $tablename $where $group_by $order_by";
+        }
+        
+        //Core_Logs_Service::debug(['message'=>'Requête:'.$queryExt]); 
+        //echo "the query " . $queryExt . PHP_EOL;var_export($data). PHP_EOL;
+        
         $stmt = empty($data) ? $db->query($queryExt) : $db->query($queryExt, $data);
 
         $rowset = [];
diff --git a/apps/maarch_entreprise/smartphone/signature_recap.php b/apps/maarch_entreprise/smartphone/signature_recap.php
index 0232e16990e0f0e89700b0a092c59c92fccf74ad..a6942596ed63c409784cdbc83b2b99abd7d37009 100644
--- a/apps/maarch_entreprise/smartphone/signature_recap.php
+++ b/apps/maarch_entreprise/smartphone/signature_recap.php
@@ -77,7 +77,12 @@ $subject = $res->subject;
     <?php
       // echo "<pre>".print_r($_SESSION['config'],true)."</pre>";
       $db = new Database();
-      $stmt = $db->query("SELECT * from res_view_attachments WHERE res_id_master = ? AND attachment_type IN ('signed_response') ORDER BY creation_date desc LIMIT 1", array($_SESSION['doc_id']));
+      //$query = "SELECT * from res_view_attachments WHERE res_id_master = ? AND attachment_type IN ('signed_response') ORDER BY creation_date desc LIMIT 1";
+      $where = "res_id_master = ? AND attachment_type IN ('signed_response')";
+      $order = " ORDER by creation_date DESC";
+      $query = $db->limit_select(0, 1, '*', 'res_view_attachments', $where, '', '', $order);
+      
+      $stmt = $db->query($query, array($_SESSION['doc_id']));
         //$_SESSION['tmpFilenameSign']
       echo '<table>';
       while($line = $stmt->fetchObject()){
diff --git a/modules/avis/class/avis_controler_Abstract.php b/modules/avis/class/avis_controler_Abstract.php
index fac928015200c14a84cf403d0c275bbecb4df845..b56ce1661516b490d917f52ebbad4a4ac685b402 100755
--- a/modules/avis/class/avis_controler_Abstract.php
+++ b/modules/avis/class/avis_controler_Abstract.php
@@ -274,11 +274,15 @@ abstract class avis_controler_Abstract
     public function myPosAvis($res_id, $coll_id, $listDiffType)
     {
         $db = new Database();
-        $stmt = $db->query("SELECT sequence, item_mode from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and item_id = ? and  process_date ISNULL ORDER BY listinstance_id ASC LIMIT 1", array($res_id, $coll_id, $listDiffType, $_SESSION['user']['UserId']));
+        $where = "res_id= ? and coll_id = ? and difflist_type = ? and item_id = ? and  process_date IS NULL";
+        $order = " ORDER by listinstance_id ASC";
+        $query = $db->limit_select(0, 1, 'sequence, item_mode', 'listinstance', $where, '', '', $order);
+
+        $stmt = $db->query($query, array($res_id, $coll_id, $listDiffType, $_SESSION['user']['UserId']));
         $res = $stmt->fetchObject();
         /* if ($res->item_mode == 'sign'){
-          return $this->nbAvis($res_id, $coll_id);
-          } */
+            return $this->nbAvis($res_id, $coll_id);
+        } */
         return $res->sequence;
     }
 
@@ -311,7 +315,11 @@ abstract class avis_controler_Abstract
         } else {
             $order = 'ASC';
         }
-        $stmt = $db->query("SELECT sequence, item_mode from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and process_date ISNULL ORDER BY listinstance_id " . $order . " LIMIT 1", array($res_id, $coll_id, $listDiffType));
+        $where = "res_id= ? and coll_id = ? and difflist_type = ? and process_date IS NULL";
+        $order = "ORDER by listinstance_id " . $order;
+        $query = $db->limit_select(0, 1, 'sequence, item_mode', 'listinstance', $where, '', '', $order);
+
+        $stmt = $db->query($query, array($res_id, $coll_id, $listDiffType));
         $res = $stmt->fetchObject();
         /* if ($res->item_mode == 'avis'){
           return $this->nbAvis($res_id, $coll_id);
@@ -323,10 +331,10 @@ abstract class avis_controler_Abstract
     {
         $stepDetails = array();
         $db = new Database();
-        $stmt = $db->query("SELECT * "
-                . "from listinstance WHERE res_id= ? and coll_id = ? "
-                . "and difflist_type = ? and sequence = ? "
-                . "ORDER BY listinstance_id ASC LIMIT 1", array($res_id, $coll_id, $listDiffType, $sequence));
+        $where = "res_id= ? and coll_id = ? and difflist_type = ? and sequence = ?";
+        $order = " ORDER by listinstance_id ASC";
+        $query = $db->limit_select(0, 1, '*', 'listinstance', $where, '', '', $order);
+        $stmt = $db->query($query, array($res_id, $coll_id, $listDiffType, $sequence));
         $res = $stmt->fetchObject();
         $stepDetails['listinstance_id'] = $res->listinstance_id;
         $stepDetails['coll_id'] = $res->coll_id;
diff --git a/modules/entities/manage_listinstance.php b/modules/entities/manage_listinstance.php
index fa9367c497277e2bacc75bb9e6a888179dfa2201..53079d749cff7f656f320980c3a1c0b67004bcc2 100755
--- a/modules/entities/manage_listinstance.php
+++ b/modules/entities/manage_listinstance.php
@@ -216,13 +216,31 @@ if (isset($_GET['what_services'])
     $PDOarray = array_merge($PDOarray, array(":whatEntity" => "%" . $what_services . "%"));
     
 }
-$users_query = 
+/*$users_query = 
     "select u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label "
     . "FROM " . $_SESSION['tablename']['users'] . " u, " . ENT_ENTITIES . " e, "
     . ENT_USERS_ENTITIES . " ue WHERE u.status <> 'DEL' and u.enabled = 'Y' and"
     . " e.entity_id = ue.entity_id and u.user_id = ue.user_id and"
     . " e.enabled = 'Y' and ue.primary_entity='Y' " . $user_expr . $entity_expr 
-    . " order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc limit 50";
+    . " order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc limit 50";*/
+
+
+$where = "u.status <> 'DEL' and u.enabled = 'Y' and"
+    . " e.entity_id = ue.entity_id and u.user_id = ue.user_id and"
+    . " e.enabled = 'Y' and ue.primary_entity='Y' " . $user_expr . $entity_expr;
+$order = "order by u.lastname asc, u.firstname asc, u.user_id asc, e.entity_label asc";
+
+$users_query = $db->limit_select(
+    0, 
+    50, 
+    'u.user_id, u.firstname, u.lastname, e.entity_id, e.entity_label', 
+    $_SESSION['tablename']['users'] . " u, " . ENT_ENTITIES . " e, " . ENT_USERS_ENTITIES . " ue", 
+    $where, 
+    '', 
+    '', 
+    $order
+);
+//echo $users_query;exit;
 
 if ($user_expr == '' && $entity_expr == '') {
     //no query
@@ -249,6 +267,22 @@ $entity_query =
         . "and  e.entity_id = ue.entity_id and u.user_id = ue.user_id and "
         . "e.enabled = 'Y' " . $user_expr . $entity_expr 
         . " group by e.entity_id, e.entity_label order by e.entity_label asc limit 50";
+
+$where = "u.status <> 'DEL' and u.enabled = 'Y'" . "and  e.entity_id = ue.entity_id and u.user_id = ue.user_id and " 
+        . "e.enabled = 'Y' " . $user_expr . $entity_expr;
+$order = "ORDER by entity_label ASC";
+$entity_query = $db->limit_select(
+    0, 
+    50, 
+    'e.entity_id,  e.entity_label', 
+    $_SESSION['tablename']['users'] . " u, " . ENT_ENTITIES . " e, " . ENT_USERS_ENTITIES . " ue",  
+    $where,
+    'group by e.entity_id, e.entity_label', 
+    '',
+    $order
+);
+//echo $entity_query;exit;
+
 if ($user_expr == '' && $entity_expr == '') {
     //no query
 } else {
diff --git a/modules/notifications/class/notifications_controler_Abstract.php b/modules/notifications/class/notifications_controler_Abstract.php
index f11f2de9a42e6e110586cbf7490015b7d2d40afe..66d3111e8e09845c67c02b46714004c8a0b30e36 100755
--- a/modules/notifications/class/notifications_controler_Abstract.php
+++ b/modules/notifications/class/notifications_controler_Abstract.php
@@ -194,7 +194,11 @@ abstract class notifications_controler_Abstract extends ObjectControler implemen
             } else { //mode == add
                 if ($this->insert($notification)) {
                     $dbConn = new Database();
-                    $stmt = $dbConn->query("SELECT notification_sid FROM notifications ORDER BY notification_sid DESC limit 1");
+                    $where = "";
+                    $order = "ORDER BY notification_sid DESC";
+                    $query = $dbConn->limit_select(0, 1, 'notification_sid', 'notifications', $where, '', '', $order);
+
+                    $stmt = $dbConn->query($query);
                     $result_sid = $stmt->fetchObject(); 
                     $control = array('status' => 'ok',
                                      'value'  => $result_sid->notification_sid);
diff --git a/modules/visa/class/class_modules_tools_Abstract.php b/modules/visa/class/class_modules_tools_Abstract.php
index 1185ac46660b8925ca2aa737e781a91622c7552b..5d6fb643099ea9d417bfe9bae18e56ed7b01eecb 100644
--- a/modules/visa/class/class_modules_tools_Abstract.php
+++ b/modules/visa/class/class_modules_tools_Abstract.php
@@ -333,7 +333,11 @@ abstract class visa_Abstract extends Database
 	
 	public function getCurrentStep($res_id, $coll_id, $listDiffType){
 		$db = new Database();
-		$stmt = $db->query("SELECT sequence, item_mode from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and process_date ISNULL ORDER BY listinstance_id ASC LIMIT 1", array($res_id, $coll_id, $listDiffType));
+		$where = "res_id= ? and coll_id = ? and difflist_type = ? and process_date IS NULL";
+        $order = "ORDER BY listinstance_id ASC";
+        $query = $db->limit_select(0, 1, 'sequence, item_mode', 'listinstance', $where, '', '', $order);
+
+		$stmt = $db->query($query, array($res_id, $coll_id, $listDiffType));
 		$res = $stmt->fetchObject();
 		if ($res->item_mode == 'sign'){
 			return $this->nbVisa($res_id, $coll_id);
@@ -355,11 +359,11 @@ abstract class visa_Abstract extends Database
 	{
 		$stepDetails = array();
 		$db = new Database();
-		$stmt = $db->query("SELECT * "
-			. "from listinstance WHERE res_id= ? and coll_id = ? "
-			. "and difflist_type = ? and sequence = ? "
-			. "ORDER BY listinstance_id ASC LIMIT 1", 
-			array($res_id, $coll_id, $listDiffType, $sequence));
+		$order = "ORDER by listinstance_id ASC";
+		$where = "res_id= ? and coll_id = ? and difflist_type = ? and sequence = ? "
+		$query = $db->limit_select(0, 1, '*', 'listinstance', $where, '', '', $order);
+
+		$stmt = $db->query($query, array($res_id, $coll_id, $listDiffType, $sequence));
 		
 		$res = $stmt->fetchObject();
 		$stepDetails['listinstance_id']   = $res->listinstance_id;
@@ -383,7 +387,11 @@ abstract class visa_Abstract extends Database
 	
 	public function myPosVisa($res_id, $coll_id, $listDiffType){
 		$db = new Database();
-		$stmt = $db->query("SELECT sequence, item_mode from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and item_id = ? and  process_date ISNULL ORDER BY listinstance_id ASC LIMIT 1", array($res_id, $coll_id, $listDiffType, $_SESSION['user']['UserId']));
+		$order = "ORDER by listinstance_id ASC";
+		$where = "res_id= ? and coll_id = ? and difflist_type = ? and item_id = ? and  process_date IS NULL"
+		$query = $db->limit_select(0, 1, 'sequence, item_mode', 'listinstance', $where, '', '', $order);
+
+		$stmt = $db->query($select, array($res_id, $coll_id, $listDiffType, $_SESSION['user']['UserId']));
 		
 		$res = $stmt->fetchObject();
 		if ($res->item_mode == 'sign'){
@@ -480,7 +488,11 @@ abstract class visa_Abstract extends Database
 		$curr_visa_wf = $this->getWorkflow($res_id, $coll_id, 'VISA_CIRCUIT');
 
 		$db = new Database();
-		$stmt = $db->query("SELECT sequence, item_mode from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and process_date ISNULL ORDER BY listinstance_id ASC LIMIT 1", array($res_id, $coll_id, 'VISA_CIRCUIT'));
+		$where = "res_id= ? and coll_id = ? and difflist_type = ? and process_date IS NULL";
+        $order = "ORDER BY listinstance_id ASC";
+        $query = $db->limit_select(0, 1, 'sequence, item_mode', 'listinstance', $where, '', '', $order);
+        
+		$stmt = $db->query($query, array($res_id, $coll_id, 'VISA_CIRCUIT'));
 		$resListDiffVisa = $stmt->fetchObject();
 
 		// If there is only one step in the visa workflow, we set status to ESIG
diff --git a/modules/visa/redirect_visa_sign.php b/modules/visa/redirect_visa_sign.php
index d0f3ebd8ce277493d567841e45c67453edf38551..ddb3ba273cd949ecf3d43f01b2b3070beea13703 100644
--- a/modules/visa/redirect_visa_sign.php
+++ b/modules/visa/redirect_visa_sign.php
@@ -231,7 +231,7 @@ function manage_form($arr_id, $history, $id_action, $label_action, $status, $col
         $circuit = $visa->getWorkflow($res_id, $coll_id, 'VISA_CIRCUIT');
 
         if (count($circuit['sign']) > 0) {
-            // $up_request = "UPDATE listinstance SET sequence = ".count($circuit['visa']).", item_mode = 'visa', process_date = CURRENT_TIMESTAMP WHERE res_id = ".$res_id." AND item_id='".$_SESSION['user']['UserId']."' AND difflist_type = 'VISA_CIRCUIT' AND process_date ISNULL ";
+            // $up_request = "UPDATE listinstance SET sequence = ".count($circuit['visa']).", item_mode = 'visa', process_date = CURRENT_TIMESTAMP WHERE res_id = ".$res_id." AND item_id='".$_SESSION['user']['UserId']."' AND difflist_type = 'VISA_CIRCUIT' AND process_date IS NULL ";
             // $db->query($up_request);
             $current_timestamp = date("Y-m-d H:i:s");
             $circuit['sign']['users'][0]['process_date'] = $current_timestamp;
diff --git a/modules/visa/rejection_visa_previous.php b/modules/visa/rejection_visa_previous.php
index 1c5615306238bdcf2526b714c35c9ccf3f693ade..9db997900c4f1c761b4abaced3ffaa2b2bb6592d 100644
--- a/modules/visa/rejection_visa_previous.php
+++ b/modules/visa/rejection_visa_previous.php
@@ -139,8 +139,11 @@ function manage_empty_error($arr_id, $history, $id_action, $label_action, $statu
     $_SESSION['action_error'] = '';
     $res_id = $arr_id[0];
 
-    $stmt = $db->query('SELECT listinstance_id FROM listinstance WHERE res_id = ? and difflist_type = ? AND process_date IS NOT NULL ORDER BY process_date DESC LIMIT 1',
-        [$res_id, 'VISA_CIRCUIT']);
+    $where = "res_id = ? and difflist_type = ? AND process_date IS NOT NULL";
+    $order = "ORDER BY process_date DESC";
+    $query = $db->limit_select(0, 1, 'listinstance_id', 'listinstance', $where, '', '', $order);
+
+    $stmt = $db->query($query,[$res_id, 'VISA_CIRCUIT']);
 
     if ($stmt->rowCount() < 1) {
         $newStatus = 'AREV';
diff --git a/modules/visa/visa_workflow.php b/modules/visa/visa_workflow.php
index 2196dba886fd90f2867b764b4e1e6290121fe6ff..86a00516370a6a3dbee5945b6a16ec04ca415289 100755
--- a/modules/visa/visa_workflow.php
+++ b/modules/visa/visa_workflow.php
@@ -42,7 +42,7 @@ $confirm = true;
 // $error_visa_workflow = false;
 
 // $db = new Database();
-// $stmt = $db->query("SELECT listinstance_id from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and process_date ISNULL", array($_POST['values'], 'letterbox_coll', 'VISA_CIRCUIT'));
+// $stmt = $db->query("SELECT listinstance_id from listinstance WHERE res_id= ? and coll_id = ? and difflist_type = ? and process_date IS NULL", array($_POST['values'], 'letterbox_coll', 'VISA_CIRCUIT'));
 
 // if ($stmt->rowCount() < 2) {
 //     $error_visa_workflow = true;