Exemple #1
0
 public static function deleteCountry()
 {
     $result = array();
     $deleted = lC_Countries_Admin::delete($_GET['cid']);
     if ($deleted) {
         $result['rpcStatus'] = RPC_STATUS_SUCCESS;
     }
     echo json_encode($result);
 }
 public static function batchDelete($batch)
 {
     global $lC_Language, $lC_Database;
     $lC_Language->loadIniFile('countries.php');
     $Qcountries = $lC_Database->query('select countries_id, countries_name from :table_countries where countries_id in (":countries_id") order by countries_name');
     $Qcountries->bindTable(':table_countries', TABLE_COUNTRIES);
     $Qcountries->bindRaw(':countries_id', implode('", "', array_unique(array_filter(array_slice($batch, 0, MAX_DISPLAY_SEARCH_RESULTS), 'is_numeric'))));
     $Qcountries->execute();
     $names_string = '';
     while ($Qcountries->next()) {
         $Qcheck = $lC_Database->query('select count(address_book_id) as total from :table_address_book where entry_country_id = :entry_country_id limit 1');
         $Qcheck->bindTable(':table_address_book', TABLE_ADDRESS_BOOK);
         $Qcheck->bindInt(':entry_country_id', $Qcountries->valueInt('countries_id'));
         $Qcheck->execute();
         if ($Qcheck->valueInt('total') > 0) {
             $names_string .= $Qcountries->valueProtected('countries_name') . ' (' . $Qcheck->valueInt('total') . ' ' . $lC_Language->get('address_book_entries') . '), ';
         }
         $Qzcheck = $lC_Database->query('select count(association_id) as total_zones from :table_zones_to_geo_zones where zone_country_id = :zone_country_id limit 1');
         $Qzcheck->bindTable(':table_zones_to_geo_zones', TABLE_ZONES_TO_GEO_ZONES);
         $Qzcheck->bindInt(':zone_country_id', $Qcountries->valueInt('countries_id'));
         $Qzcheck->execute();
         if ($Qzcheck->valueInt('total_zones') > 0) {
             $names_string .= $Qcountries->valueProtected('countries_name') . ' (' . $Qzcheck->valueInt('total_zones') . ' ' . $lC_Language->get('tax_zones') . '), ';
         }
         if ($Qzcheck->valueInt('total_zones') == 0 && $Qcheck->valueInt('total') == 0) {
             lC_Countries_Admin::delete($Qcountries->valueInt('countries_id'));
         }
         $Qcheck->freeResult();
         $Qzcheck->freeResult();
     }
     if (!empty($names_string)) {
         $names_string = substr($names_string, 0, -2);
     }
     $result['namesString'] = $names_string;
     $Qcountries->freeResult();
     return $result;
 }