/**
  * Lists all Emission entities.
  */
 public function indexAction()
 {
     $breadcrumbs = $this->get("white_october_breadcrumbs");
     $breadcrumbs->addItem('Les émissions');
     $breadcrumbs->addItem('Grille des programmes');
     $format = $this->get('request')->get('_format');
     $timestampDay = 60 * 60 * 24;
     $timestampWeek = $timestampDay * 7;
     if (!empty($_GET['date'])) {
         $start = new \Datetime($_GET['date']);
         if ($start->format('W') != 1) {
             $start->setISODate($start->format('Y'), $start->format('W'), 1);
         }
     } elseif (!empty($_GET['week'])) {
         $start = new \Datetime();
         $start->setISODate($start->format('Y'), $_GET['week'], 1);
     }
     if (empty($start)) {
         $start = new \Datetime('now');
         $start->setTime(0, 0);
     }
     $weekNumber = $start->format('W');
     // find programs on current week
     $dayNumber = $start->format('w');
     if ($dayNumber === 0) {
         $start->modify('-6 days');
     } elseif ($dayNumber > 1) {
         $start->modify('-' . ($dayNumber - 1) . ' days');
     }
     $stop = clone $start;
     $stop->modify('+7 days');
     $em = $this->getDoctrine()->getManager();
     $query = $em->createQuery("SELECT p FROM ProgramBundle:Program p WHERE p.time_stop < :stop AND p.time_start >= :start AND p.time_start < p.time_stop  ORDER BY p.time_start ASC, p.time_stop DESC")->setParameters(array('start' => $start, 'stop' => $stop));
     $results = $query->getResult();
     $entities = array();
     for ($i = 0; $i < 7; $i++) {
         $day = clone $start;
         $day->modify("+{$i} days");
         $entities[] = array('date' => $day, 'tot' => array('label' => 'Tôt', 'desc' => 'Avant 7h00', 'entities' => array()), 'am' => array('label' => 'Matinée', 'desc' => '7h00 - 12h00', 'entities' => array()), 'pm' => array('label' => 'Après-midi', 'desc' => '12h00 - 18h00', 'entities' => array()), 'soir' => array('label' => 'Soirée', 'desc' => '18h00 - 21h00', 'entities' => array()), 'nuit' => array('label' => 'Nuit', 'desc' => 'Après 21h00', 'entities' => array()));
     }
     foreach ($results as $result) {
         $weekDay = $result->getTimeStart()->format('N') - 1;
         if ($result->getTimeStart()->format('H:i:s') < '07:00:00') {
             $entities[$weekDay]['tot']['entities'][] = $result;
         } elseif ($result->getTimeStart()->format('H:i:s') < '12:00:00') {
             $entities[$weekDay]['am']['entities'][] = $result;
         } elseif ($result->getTimeStart()->format('H:i:s') < '18:00:00') {
             $entities[$weekDay]['pm']['entities'][] = $result;
         } elseif ($result->getTimeStart()->format('H:i:s') < '21:00:00') {
             $entities[$weekDay]['soir']['entities'][] = $result;
         } else {
             $entities[$weekDay]['nuit']['entities'][] = $result;
         }
     }
     return $this->render(sprintf('ProgramBundle:Program:index.%s.twig', $format), array('entities' => $entities, 'count' => count($results), 'weekNumber' => $weekNumber, 'start' => $start, 'stop' => $stop));
 }
Ejemplo n.º 2
0
 public function setUp()
 {
     parent::setUp();
     $date = new Datetime();
     $dmax = $date->format("Y-m-d H:i:s");
     $date->modify('-6 month');
     $dmin = $date->format("Y-m-d H:i:s");
     $databoxes = self::$DI['app']->getDataboxes();
     $ret = [];
     foreach ($databoxes as $databox) {
         $colls = $databox->get_collections();
         $rett = [];
         foreach ($colls as $coll) {
             $rett[$coll->get_coll_id()] = $coll->get_coll_id();
         }
         $ret[$databox->get_sbas_id()] = implode(',', $rett);
     }
     foreach ($ret as $sbasid => $collections) {
         $report = new module_report_connexion(self::$DI['app'], $dmin, $dmax, $sbasid, $collections);
         if (!$this->report instanceof module_report) {
             $this->report = $report;
         } elseif ($report->getTotal() > $this->report->getTotal()) {
             $this->report = $report;
         }
     }
     $this->report->setFilter([['f' => 'user', 'o' => '=', 'v' => 'admin'], ['f' => 'ddate', 'o' => 'LIKE', 'v' => '*'], ['f' => '1', 'o' => 'OR', 'v' => '1']]);
     $this->report->setUser_id(self::$DI['user']->getId());
     $this->report->setOrder('user', 'ASC');
     $this->filter = new module_report_sqlfilter(self::$DI['app'], $this->report);
 }
Ejemplo n.º 3
0
 public function addInvoiceFromTickets($clientId, $tickets, $month)
 {
     if (!$clientId) {
         return array('success' => false, 'message' => 'Le code client est inconnu sur Dolibarr', 'id' => null);
     }
     $now = new \Datetime();
     $date31 = new \Datetime($month->format('Y-m') . '-01');
     $date31->modify('+1 month');
     $date31->modify('-1 day');
     $invoice = new Invoice();
     $invoice->setCustomerCode($clientId);
     $invoice->setAuthorId(1);
     $invoice->setDate($date31);
     $invoice->setDateDue($date31);
     $invoice->setDateCreated($now);
     $invoice->setType(0);
     usort($tickets, array($this, 'sortTicket'));
     foreach ($tickets as $ticket) {
         $description = '';
         if (strpos($ticket['entity']['name'], 'MARE NOSTRUM >') || strpos($ticket['entity']['name'], 'MALURA')) {
             $description = $ticket['entity']['name'] . '<br/>';
         }
         $invoice_line = new InvoiceLine($invoice);
         $invoice_line->setType(1);
         $invoice_line->setDescription('<em>' . $ticket['solvedate']->format('d-m-Y') . '</em> : ' . $description . $ticket['name'] . '<br/>' . $ticket['content']);
         $invoice_line->setTva($this->tva * 100);
         $invoice_line->setQuantity(number_format($this->formatActionTime($ticket['actiontime']) / 60 / 60, 2));
         $invoice_line->setUnitPrice($this->unit_price);
         $invoice_line->setDateStart($ticket['date']);
         $invoice_line->setDateEnd($ticket['solvedate']);
         $invoice_line->calculTotals();
     }
     $result = $this->dolibarr_invoice_connector->addInvoice($invoice);
     if ($result['result']->result_code == 'OK') {
         return array('success' => true, 'message' => $result['ref'], 'id' => $result['id']);
     } else {
         return array('success' => false, 'message' => $result['result']->result_label, 'id' => null);
     }
 }
Ejemplo n.º 4
0
 /**
  * @Route("/program/{date}.{_format}", defaults={"date": "now", "_format": "html"}, name="oktothek_tv_program_for_date")
  * @Template
  */
 public function programAction(Request $request, $date = "now")
 {
     $start = new \Datetime($date);
     $start->setTime(8, 0);
     $end = new \Datetime($date);
     $end->modify('+1 day');
     $end->setTime(8, 0);
     if ($request->getMethod() != "GET") {
         $start = new \Datetime($request['start']);
         $end = new \Datetime($request['end']);
     }
     $shows = $this->get('oktothek_tv')->getShows($start, $end);
     return ['shows' => $shows, 'datetime' => $start, 'date' => $start];
 }
 /**
  * {@inheritdoc}
  */
 protected function createLock()
 {
     try {
         $ttl = null;
         if (isset($this->options['ttl']) && $this->options['ttl'] !== 0) {
             $now = new \Datetime('now');
             $ttl = $this->options['ttl'];
             $ttl = $now->modify(sprintf('+%s seconds', $ttl))->format('Y-m-d H:i:s');
         }
         $status = $this->queryDriver->insertQuery($ttl);
     } catch (\Exception $e) {
         $status = false;
     }
     return $status;
 }
Ejemplo n.º 6
0
 /**
  * 验证 Token 并使其登录
  * @author zhengqian.zhu@dajiayao.cc
  */
 protected function verifyToken($tokenStr)
 {
     // TODO: Redis 缓存 Token
     // 判断 Token 有效性
     $token = App::where('access_token', '=', $tokenStr)->where('expire_at', '>', date("Y-m-d H:i:s"))->first();
     if (!$token) {
         return false;
     }
     // 延长 Token 的有效期
     $today = new \Datetime();
     $modifier = '+2 hours';
     $token->expire_at = $today->modify($modifier);
     $token->save();
     return $token->app_id;
 }
Ejemplo n.º 7
0
 public function setUp()
 {
     parent::setUp();
     $date = new Datetime();
     $this->dmax = $date->format("Y-m-d H:i:s");
     $date->modify('-6 month');
     $this->dmin = $date->format("Y-m-d H:i:s");
     $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes();
     $this->ret = [];
     foreach ($databoxes as $databox) {
         $colls = $databox->get_collections();
         $rett = [];
         foreach ($colls as $coll) {
             $rett[$coll->get_coll_id()] = $coll->get_coll_id();
         }
         $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
     }
 }
Ejemplo n.º 8
0
 public function getTicketforMonth($month, $etat = null)
 {
     $start_date = new \Datetime($month->format('Y-m' . '-01'));
     $end_date = new \Datetime($month->format('Y-m' . '-01'));
     $start_date->modify('-6 month');
     $end_date->modify('+1 month');
     $tickets = $this->ticket_connector->getTicketsFromGLPI($start_date, $end_date, null, null, 'entities_id', 99999, 'facturable', $etat);
     $return_tickets = array();
     for ($i = 0; $i < count($tickets); $i++) {
         if ($tickets[$i]["solvedate"]->format('m') == $month->format('m')) {
             $tickets[$i]['entity'] = $this->entity_service->getEntity($tickets[$i]['entities_id']);
             $tickets[$i]['id_client_dolibar'] = $this->dolibarr_service->getClientIdFromCodeClient($tickets[$i]['entity']['comment']);
             $tickets[$i]['user'] = $this->user_service->getUser($tickets[$i]['users']['assign'][0]['id']);
             $return_tickets[] = $tickets[$i];
         }
     }
     usort($return_tickets, array($this, "sortTickets"));
     return $return_tickets;
 }
 public function historyAction($year = '', $month = '')
 {
     if ($year == '') {
         $year = date('Y');
     }
     if ($month == '') {
         $month = date('F');
     }
     $month_date = new \Datetime($month . ' ' . $year);
     $d3_days = '[';
     $days_number = cal_days_in_month(CAL_GREGORIAN, $month_date->format('m'), $year);
     $start_date = $month_date->modify('first day of this month')->format('Y-m-d');
     for ($i = 0; $i < $days_number; $i++) {
         $date = strtotime(date("Y-m-d", strtotime($start_date)) . " {$i} day");
         $d3_days .= '"' . date('l jS', $date) . '",';
     }
     $d3_days .= '];';
     $template_vars = array('month_name' => $month, 'd3_days' => $d3_days, 'year_number' => $year, 'month_number' => $month);
     return $this->render('PowerGridBundle:Default:history.html.twig', $template_vars);
 }
Ejemplo n.º 10
0
 public function login($u_id)
 {
     $user = User::find($u_id);
     if (empty($user)) {
         throw new Exception("没有找到用户", 3005);
     }
     if ($user->u_status != 1) {
         throw new Exception("您的账号不可用, 请联系客服", 3005);
     }
     $re = [];
     $re['token'] = $user->u_token;
     $now = new Datetime();
     $now->modify('+ 30 days');
     $re['expire'] = $now->format('Y-m-d H:i:s');
     $re['id'] = $user->u_id;
     $re['name'] = $user->u_name = $this->u_nickname;
     $re['nickname'] = $user->u_nickname = $this->u_nickname;
     $re['invite_code'] = $user->u_invite_code;
     $re['head_img'] = $user->u_head_img = $this->u_head_img;
     $re['biograph'] = $user->u_biograph;
     $school = DicSchool::find($user->u_school_id);
     if (empty($school)) {
         $re['city'] = null;
         $re['school'] = null;
     } else {
         $re['city'] = DicCity::where('c_id', '=', $school->t_city)->where('c_province_id', '=', $school->t_province)->first()->showInList();
         $re['school'] = $school->showInList();
     }
     $user->save();
     $re['gender'] = $user->u_sex;
     $user->load('booths');
     $booths = null;
     if (!empty($user->booths)) {
         foreach ($user->booths as $key => $booth) {
             $booths[] = $booth->showInLogin();
         }
     }
     $re['boohts'] = $booths;
     return $re;
 }
Ejemplo n.º 11
0
 /**
  * Hierbei handelt es sich um eine Funktion, die über die URL nicht aufgerufen werden kann.
  * Stattdessen wird sie vom AutoController aufgerufen, wenn die Ferien automatisch importiert werden sollen
  * Dabei werden Daten, die bereits als Specialdate markiert sind, übersprungen.
  *
  * @author aloeser
  * @return void
  */
 public function importVacations()
 {
     try {
         $importyear = date('Y') + 1;
         $sourceURL = 'http://www.schulferien.org/iCal/Ferien/icals/Ferien_Berlin_' . $importyear . '.ics';
         $icalreader = new ICal($sourceURL);
         $events = $icalreader->events();
         if ($events == array()) {
             //Die angegebene Datei existiert nicht
             throw new Exception();
         }
         $tmpSpecialdates = $this->Specialdate->find('all', array('recursive' => -1, 'conditions' => array('Specialdate.date LIKE ' => $importyear . '-__-__')));
         $specialdates = array();
         foreach ($tmpSpecialdates as $tmpSpecialdate) {
             array_push($specialdates, $tmpSpecialdate['Specialdate']['date']);
         }
         foreach ($events as $event) {
             $timeBegin = $this->icalToUnixtime($event['DTSTART']);
             $timeEnd = $this->icalToUnixtime($event['DTEND']);
             $datetime = new Datetime(date('Y-m-d', $timeBegin));
             for ($i = $timeBegin; $i <= $timeEnd; $i += DAY) {
                 $dateString = $datetime->format('Y-m-d');
                 if (!in_array($dateString, $specialdates)) {
                     //Datum existiert noch nicht
                     if (!($datetime->format('N') >= 6)) {
                         //Kein Wochenende -> Specialdate eintragen, um das Datum zu deaktivieren
                         $this->Specialdate->create();
                         $this->Specialdate->save(array('Specialdate' => array('date' => $dateString)));
                     }
                 } else {
                     //Datum existiert bereits
                 }
                 $datetime->modify("+1 day");
             }
         }
         AutoController::saveLog('Ferienimport', 0, 'SpecialdatesController', 'importVacations');
     } catch (Exception $e) {
         AutoController::saveLog('Ferienimport', 3, 'SpecialdatesController', 'importVacations');
     }
 }
Ejemplo n.º 12
0
function verificarFeriado($dataHora)
{
    try {
        $mongo = new MongoClient('mongodb://*****:*****@localhost:27017');
        $db = $mongo->twitterdb;
        $collection = $db->createCollection("data");
        $dados = $collection->find();
        foreach ($dados as $document) {
            $data = date("d-m-Y", strtotime(str_replace("/", "-", $document["data"])));
            $diaSem = date("N", strtotime(str_replace("/", "-", $document["data"])));
            // Inicializa a data inicial e final
            $dataIni = $data;
            $dataFim = $data;
            // semana comeca na segunda, quarta � dia 3. A semana comeca no dia 1
            if ($diaSem < 3) {
                // Feriado no inicio da semana, considera feriadao do dia do feriado at� dia 1
                $qtdeDias = $diaSem + 1;
                $d = new Datetime($data);
                $d->modify("-" . $qtdeDias . " days");
                $dataIni = date("d-m-Y", strtotime($d->format('d-m-Y')));
            } else {
                if ($diaSem > 3) {
                    // Feriado no Fim da semana, condidera feriado do dia 7 at� o dia do feriado
                    $qtdeDias = 7 - $diaSem;
                    $d = new Datetime($data);
                    $d->modify("+" . $qtdeDias . " days");
                    $dataFim = date("d-m-Y", strtotime($d->format("d-m-Y")));
                }
            }
            if (strtotime($dataHora) >= strtotime($dataIni) && strtotime($dataHora) <= strtotime($dataFim)) {
                return "sim";
            }
        }
        return "nao";
    } catch (Exception $e) {
        echo '<h3>N�o foi possivel conectar no banco de dados.</h3>';
        return "nao";
    }
}
Ejemplo n.º 13
0
 public function setUp()
 {
     parent::setUp();
     $this->xml = '<?xml version="1.0" encoding="UTF-8"?>
     <record record_id="299">
       <description>
         <report ok="1">hello</report>
       </description>
      </record>';
     $date = new Datetime();
     $this->dmax = $date->format("Y-m-d H:i:s");
     $date->modify('-6 month');
     $this->dmin = $date->format("Y-m-d H:i:s");
     $databoxes = self::$DI['app']['phraseanet.appbox']->get_databoxes();
     $this->ret = [];
     foreach ($databoxes as $databox) {
         $colls = $databox->get_collections();
         $rett = [];
         foreach ($colls as $coll) {
             $rett[$coll->get_coll_id()] = $coll->get_coll_id();
         }
         $this->ret[$databox->get_sbas_id()] = implode(',', $rett);
     }
 }
Ejemplo n.º 14
0
 public function isValid($value, $required)
 {
     if ($required && empty($value) || !isset($this->fieldId)) {
         return false;
     }
     $max_range = $this->params->get('maxrange');
     $min_range = $this->params->get('minrange');
     $value = JFactory::getDate(strtotime($value))->toUnix();
     $max_ok = true;
     $min_ok = true;
     //$ret = true;
     if ($max_range) {
         if (strtotime($max_range)) {
             $max_range = JFactory::getDate(strtotime($max_range))->toUnix();
             $max_ok = $value < $max_range;
         } elseif (is_numeric($max_range) && intval($max_range) > 0) {
             //consider as age format
             $datetime = new Datetime();
             $datetime->modify('-' . $max_range . ' year');
             $max_range = $datetime->format('U');
             //revert the age comparation
             $max_ok = $value > $max_range;
         } else {
             $max_range = 0;
         }
     }
     if ($min_range) {
         if (strtotime($min_range)) {
             $min_range = JFactory::getDate(strtotime($min_range))->toUnix();
             $min_ok = $value > $min_range;
         } elseif (is_numeric($min_range) && intval($min_range) > 0) {
             //consider as age format
             $datetime = new Datetime();
             $datetime->modify('-' . $min_range . ' year');
             $min_range = $datetime->format('U');
             //revert the age comparation
             $min_ok = $value < $min_range;
         } else {
             $min_range = 0;
         }
     }
     return $max_ok && $min_ok ? true : false;
     //return $ret;
 }
Ejemplo n.º 15
0
    public function hookbackOfficeTop($no_cron = true)
    {
        if (Tools::strtolower(Tools::getValue('controller')) == 'adminorders' && Configuration::get('SHOPPING_FLUX_ORDERS') != '' && in_array('curl', get_loaded_extensions()) || $no_cron == false) {
            $ordersXML = $this->_callWebService('GetOrders');
            if (count($ordersXML->Response->Orders) == 0) {
                return;
            }
            foreach ($ordersXML->Response->Orders->Order as $order) {
                try {
                    $orderExists = Db::getInstance()->getRow('SELECT m.id_message  FROM ' . _DB_PREFIX_ . 'message m
						WHERE m.message LIKE "%' . pSQL($order->IdOrder) . '%"');
                    if (isset($orderExists['id_message'])) {
                        $this->_validOrders((string) $order->IdOrder, (string) $order->Marketplace);
                        continue;
                    }
                    $mail = (string) $order->BillingAddress->Email;
                    $email = empty($mail) ? pSQL($order->IdOrder . '@' . $order->Marketplace . '.sf') : pSQL($mail);
                    $id_customer = $this->_getCustomer($email, (string) $order->BillingAddress->LastName, (string) $order->BillingAddress->FirstName);
                    //avoid update of old orders by the same merchant with different addresses
                    $id_address_billing = $this->_getAddress($order->BillingAddress, $id_customer, 'Billing-' . (string) $order->IdOrder);
                    $id_address_shipping = $this->_getAddress($order->ShippingAddress, $id_customer, 'Shipping-' . (string) $order->IdOrder);
                    $products_available = $this->_checkProducts($order->Products);
                    $current_customer = new Customer((int) $id_customer);
                    $last_cart = new Cart($current_customer->getLastCart());
                    $add = true;
                    if ($last_cart->id) {
                        $date_cart = date_create($last_cart->date_add);
                        $date = new Datetime();
                        $date->modify('-5 min');
                        if ($date < $date_cart) {
                            $add = false;
                        }
                    }
                    if ($products_available && $id_address_shipping && $id_address_billing && $id_customer && $add) {
                        $cart = $this->_getCart($id_customer, $id_address_billing, $id_address_shipping, $order->Products, (string) $order->Currency, (string) $order->ShippingMethod);
                        if ($cart) {
                            //compatibylity with socolissmo
                            $this->context->cart = $cart;
                            Db::getInstance()->autoExecute(_DB_PREFIX_ . 'customer', array('email' => '*****@*****.**'), 'UPDATE', '`id_customer` = ' . (int) $id_customer);
                            $customerClear = new Customer();
                            if (method_exists($customerClear, 'clearCache')) {
                                $customerClear->clearCache(true);
                            }
                            $payment = $this->_validateOrder($cart, $order->Marketplace);
                            $id_order = $payment->currentOrder;
                            //we valid there
                            $this->_validOrders((string) $order->IdOrder, (string) $order->Marketplace, $id_order);
                            $reference_order = $payment->currentOrderReference;
                            Db::getInstance()->autoExecute(_DB_PREFIX_ . 'customer', array('email' => pSQL($email)), 'UPDATE', '`id_customer` = ' . (int) $id_customer);
                            Db::getInstance()->autoExecute(_DB_PREFIX_ . 'message', array('id_order' => $id_order, 'message' => 'Numéro de commande ' . pSQL($order->Marketplace) . ' :' . pSQL($order->IdOrder), 'date_add' => date('Y-m-d H:i:s')), 'INSERT');
                            $this->_updatePrices($id_order, $order, $reference_order);
                        }
                    }
                    $cartClear = new Cart();
                    if (method_exists($cartClear, 'clearCache')) {
                        $cartClear->clearCache(true);
                    }
                    $addressClear = new Address();
                    if (method_exists($addressClear, 'clearCache')) {
                        $addressClear->clearCache(true);
                    }
                    $customerClear = new Customer();
                    if (method_exists($customerClear, 'clearCache')) {
                        $customerClear->clearCache(true);
                    }
                } catch (PrestaShopException $pe) {
                    $this->_validOrders((string) $order->IdOrder, (string) $order->Marketplace, false, $pe->getMessage());
                }
            }
        }
    }
 public function hookbackOfficeTop()
 {
     if (Tools::getValue('controller') == 'adminorders' && Configuration::get('SHOPPING_FLUX_ORDERS') != '' && in_array('curl', get_loaded_extensions())) {
         $ordersXML = $this->_callWebService('GetOrders');
         foreach ($ordersXML->Response->Orders->Order as $order) {
             $this->_validOrders((string) $order->IdOrder, (string) $order->Marketplace);
             $mail = strval($order->BillingAddress->Email);
             $email = empty($mail) ? pSQL($order->IdOrder . '@' . $order->Marketplace . '.sf') : pSQL($mail);
             $id_customer = $this->_getCustomer($email, strval($order->BillingAddress->LastName), strval($order->BillingAddress->FirstName));
             $id_customer_shipping = $this->_getCustomer($email, strval($order->ShippingAddress->LastName), strval($order->ShippingAddress->FirstName));
             $id_address_billing = $this->_getAddress($order->BillingAddress, $id_customer, 'Billing');
             $id_address_shipping = $this->_getAddress($order->ShippingAddress, $id_customer_shipping, 'Shipping');
             $products_available = $this->_checkProducts($order->Products);
             $current_customer = new Customer((int) $id_customer);
             $last_cart = new Cart($current_customer->getLastCart());
             $add = true;
             if ($last_cart->id) {
                 $date_cart = date_create($last_cart->date_add);
                 $date = new Datetime();
                 $date->modify('-5 min');
                 if ($date < $date_cart) {
                     $add = false;
                 }
             }
             if ($products_available && $id_address_shipping && $id_address_billing && $id_customer && $id_customer_shipping && $add) {
                 $cart = $this->_getCart($id_customer, $id_address_billing, $id_address_shipping, $order->Products);
                 if ($cart) {
                     Db::getInstance()->autoExecute(_DB_PREFIX_ . 'customer', array('email' => '*****@*****.**'), 'UPDATE', '`id_customer` = ' . (int) $id_customer);
                     $customerClear = new Customer();
                     if (method_exists($customerClear, 'clearCache')) {
                         $customerClear->clearCache(true);
                     }
                     $payment = $this->_validateOrder($cart, $order->Marketplace);
                     $id_order = $payment->currentOrder;
                     $reference_order = $payment->currentOrderReference;
                     Db::getInstance()->autoExecute(_DB_PREFIX_ . 'customer', array('email' => pSQL($email)), 'UPDATE', '`id_customer` = ' . (int) $id_customer);
                     Db::getInstance()->autoExecute(_DB_PREFIX_ . 'message', array('id_order' => $id_order, 'message' => 'Numéro de commande ' . $order->Marketplace . ' :' . $order->IdOrder, 'date_add' => date('Y-m-d H:i:s')), 'INSERT');
                     $this->_updatePrices($id_order, $order, $reference_order);
                 }
             }
             $cartClear = new Cart();
             if (method_exists($cartClear, 'clearCache')) {
                 $cartClear->clearCache(true);
             }
             $addressClear = new Address();
             if (method_exists($addressClear, 'clearCache')) {
                 $addressClear->clearCache(true);
             }
             $customerClear = new Customer();
             if (method_exists($customerClear, 'clearCache')) {
                 $customerClear->clearCache(true);
             }
         }
     }
 }
 /**
  * Retrieve a reasonable set of default options to be used for
  * newly defined groups until the user sets their own options
  *
  * @return array
  *
  * @author Ken Auberry <*****@*****.**>
  */
 public function get_group_option_defaults()
 {
     $DB_prefs = $this->load->database('website_prefs', TRUE);
     $query = $DB_prefs->get('reporting_object_group_option_defaults');
     $defaults = array();
     if ($query && $query->num_rows() > 0) {
         foreach ($query->result() as $row) {
             if ($row->option_type == 'start_time' && ($row->option_default = 0)) {
                 $start_time = new Datetime();
                 $row->option_default = $start_time->format('Y-m-d');
             }
             if ($row->option_type == 'end_time' && ($row->option_default = 0)) {
                 $end_time = new Datetime();
                 $end_time->modify('-1 week');
                 $row->option_default = $end_time->format('Y-m-d');
             }
             $defaults[$row->option_type] = $row->option_default;
         }
     }
     return $defaults;
 }
Ejemplo n.º 18
0
use Symfony\Component\Debug\Debug;
use Symfony\Component\Debug\ErrorHandler;
use Symfony\Component\Debug\ExceptionHandler;
// Initialize Debugging by SYmfony 2...
Debug::enable();
ErrorHandler::register();
ExceptionHandler::register();
echo "<h2>Utilisateurs </h2>";
//throw new CustomException(404,'coucou');
/**
 * Manipulation des dates avec Datetime
 */
$datenow = new \Datetime('now');
echo "Date du jour : " . $datenow->format('d/m/Y');
echo "<br />";
$dateyesterday = $datenow->modify('-1 day');
echo "Date d'y hier : " . $datenow->format('d/m/Y');
echo "<br />";
$dateweek = $datenow->modify('-1 week');
echo "Date il y a 1 semaine : " . $dateweek->format('d/m/Y');
echo "<br />";
$datemonth = $datenow->modify('+ 2  month');
echo "Date dans 2 mois : " . $datemonth->format('d/m/Y');
echo "<br />";
$dateyear = $datenow->modify('+ 1  year');
echo "Date dans 1 an : " . $dateyear->format('d/m/Y');
echo "<br />";
//        $date = new \DateTime('06/01/2014');
$date = \DateTime::createFromFormat('d/m/Y', '06/01/2014');
echo "Date " . $date->format('d/m/Y');
//instanciation : création de 2 objets User
Ejemplo n.º 19
0
 public function indexAction()
 {
     $totalSales = 0;
     $unpaidInvoicesAmount = 0;
     $todaySales = 0;
     $thisMonthSales = 0;
     $date = new \Datetime('now');
     $dateTmp = new \Datetime('now');
     $lastMonths = array();
     $lastMonths[] = array('name' => $dateTmp->format('Y-m'), 'count' => 0);
     $lastMonths[] = array('name' => $dateTmp->modify('-1 month')->format('Y-m'), 'count' => 0);
     $lastMonths[] = array('name' => $dateTmp->modify('-1 month')->format('Y-m'), 'count' => 0);
     $lastMonths[] = array('name' => $dateTmp->modify('-1 month')->format('Y-m'), 'count' => 0);
     $lastMonths[] = array('name' => $dateTmp->modify('-1 month')->format('Y-m'), 'count' => 0);
     $lastMonths[] = array('name' => $dateTmp->modify('-1 month')->format('Y-m'), 'count' => 0);
     $month = $date->format('F');
     $today = $date->format('Y-m-d');
     $thisMonth = $date->format('m');
     $orders = $this->getDoctrine()->getRepository('HostkitCoreBundle:Order')->findAll();
     $invoices = $this->getDoctrine()->getRepository('HostkitCoreBundle:Invoice')->findAll();
     $unpaidInvoices = $this->getDoctrine()->getRepository('HostkitCoreBundle:Invoice')->findBy(array('status' => 1));
     $orderItems = $this->getDoctrine()->getRepository('HostkitCoreBundle:OrderItem')->findAll();
     $openSupportTickets = $this->getDoctrine()->getRepository('HostkitCoreBundle:SupportTicket')->findBy(array('status' => 1));
     $openSupportTickets = count($openSupportTickets);
     $answeredSupportTickets = $this->getDoctrine()->getRepository('HostkitCoreBundle:SupportTicket')->findBy(array('status' => 2));
     $answeredSupportTickets = count($answeredSupportTickets);
     $closedSupportTickets = $this->getDoctrine()->getRepository('HostkitCoreBundle:SupportTicket')->findBy(array('status' => 3));
     $closedSupportTickets = count($closedSupportTickets);
     $activeClients = $this->getDoctrine()->getRepository('HostkitCoreBundle:Client')->findBy(array('status_id' => 2));
     $activeClients = count($activeClients);
     $inactiveClients = $this->getDoctrine()->getRepository('HostkitCoreBundle:Client')->findBy(array('status_id' => 1));
     $inactiveClients = count($inactiveClients);
     foreach ($lastMonths as $key => $lastMonth) {
         foreach ($orders as $order) {
             $orderDate = $order->getOrderDate();
             $orderDate = new \Datetime($orderDate);
             if ($lastMonth['name'] == $orderDate->format('Y-m')) {
                 if (isset($lastMonths[$key]['count'])) {
                     $lastMonths[$key]['count'] = $lastMonths[$key]['count'] + 1;
                 } else {
                     $lastMonths[$key]['count'] = 1;
                 }
             }
         }
     }
     foreach ($orders as $order) {
         $orderDateTmp = $order->getOrderDate();
         $orderDateTmp = new \Datetime($orderDateTmp);
         $orderDate = $orderDateTmp->format('Y-m-d');
         $orderMonth = $orderDateTmp->format('m');
         $totalSales = number_format($totalSales + $order->getAmount(), 2);
         if ($orderDate == $today) {
             $todaySales = number_format($todaySales + $order->getAmount(), 2);
         }
         if ($orderMonth == $thisMonth) {
             $thisMonthSales = number_format($thisMonthSales + $order->getAmount(), 2);
         }
     }
     foreach ($orderItems as $orderItem) {
     }
     foreach ($unpaidInvoices as $unpaidInvoice) {
         $unpaidInvoicesAmount = number_format($unpaidInvoicesAmount + $unpaidInvoice->getAmount(), 2);
     }
     return $this->render('HostkitAdminBundle:Default:dashboard.html.twig', array('totalSales' => $totalSales, 'todaySales' => $todaySales, 'thisMonthSales' => $thisMonthSales, 'thisMonth' => $month, 'unpaidInvoicesAmount' => $unpaidInvoicesAmount, 'closedSupportTickets' => $closedSupportTickets, 'openSupportTickets' => $openSupportTickets, 'answeredSupportTickets' => $answeredSupportTickets, 'inactiveClients' => $inactiveClients, 'activeClients' => $activeClients, 'lastMonths' => $lastMonths));
 }
Ejemplo n.º 20
0
 public function generateOrderPdfAction($orderId)
 {
     $userId = $this->getUser()->getId();
     $today = new \Datetime('now');
     $today = $today->format('d-m-Y');
     $total = 0;
     $subtotal = 0;
     $order = $this->getDoctrine()->getRepository('HostkitCoreBundle:Order')->find($orderId);
     $payment = $this->getDoctrine()->getRepository('HostkitCoreBundle:Payment')->find(1);
     $settings = $this->getDoctrine()->getRepository('HostkitCoreBundle:Settings')->find(1);
     $client = $this->getDoctrine()->getRepository('HostkitCoreBundle:Client')->findBy(array('user_id' => $userId));
     $orderItems = $this->getDoctrine()->getRepository('HostkitCoreBundle:OrderItem')->findBy(array('order_id' => $order->getId()));
     foreach ($orderItems as $orderItem) {
         $orderItem->setCreatedAt($orderItem->getCreatedAt()->format('d-m-Y'));
         if ($orderItem->getPackageId() > 0) {
             $product = $this->getDoctrine()->getRepository('HostkitCoreBundle:Product')->find($orderItem->getPackageId());
             $orderItem->setPackageId($product->getName());
         } else {
             $details = explode(',', $orderItem->getDetails());
             $orderItem->setPackageId($details[0]);
         }
         $subtotal = number_format($subtotal + $orderItem->getPrice(), 2);
         $total = number_format($subtotal + ($orderItem->getPrice() + $orderItem->getPrice() * $payment->getVat() / 100), 2);
     }
     $paymentTill = new \Datetime($order->getOrderDate());
     $paymentTill->modify('+10 day');
     $paymentTill = $paymentTill->format('d-m-Y');
     $client = $client[0];
     $html = $this->renderView('HostkitClientBundle:Invoice:detail-order.html.twig', array('order' => $order, 'settings' => $settings, 'client' => $client, 'today' => $today, 'orderItems' => $orderItems, 'payment' => $payment, 'total' => $total, 'subtotal' => $subtotal, 'paymentTill' => $paymentTill));
     //return new Response('generated pdf');
     return new Response($this->get('knp_snappy.pdf')->getOutputFromHtml($html), 200, array('Content-Type' => 'application/pdf', 'Content-Disposition' => 'attachment; filename="file.pdf"'));
 }
Ejemplo n.º 21
0
 private function _birthdateFieldHelper(&$obj)
 {
     $is_age = true;
     $obj->fieldType = 'birthdate';
     //If value is not array, pass it back as array
     //if(!is_array($obj->value)){
     //            $obj->value = explode(',',$obj->value);
     //        }
     //detecting search by age or date
     if (is_array($obj->value) && strtotime($obj->value[0]) !== false && strtotime($obj->value[1]) !== false || !is_array($obj->value) && strtotime($obj->value)) {
         $is_age = false;
     } else {
         //the input value must be unsign number, else return
         if (is_array($obj->value)) {
             if (!is_numeric($obj->value[0]) || !is_numeric($obj->value[1]) || intval($obj->value[0]) < 0 || intval($obj->value[1]) < 0) {
                 //invalid range, reset to 0
                 $obj->value[0] = 0;
                 $obj->value[1] = 0;
                 return;
             }
             $obj->value[0] = intval($obj->value[0]);
             $obj->value[1] = intval($obj->value[1]);
         } else {
             if (!is_numeric($obj->value) || intval($obj->value) < 0) {
                 //invalid range, reset to 0
                 $obj->value = 0;
                 return;
             }
             $obj->value = intval($obj->value);
         }
     }
     // correct the age order
     if (is_array($obj->value) && $obj->value[1] > $obj->value[0]) {
         $obj->value = array_reverse($obj->value);
     }
     // TODO: something is wrong with comparing the datetime value
     // in text type instead of datetime type,
     // e.g. BETWEEN '1955-09-07 00:00:00' AND '1992-09-07 23:59:59'
     // we can't find '1992-02-26 23:59:59' in the result.
     if ($obj->condition == 'between') {
         if ($is_age) {
             $year0 = $obj->value[0] + 1;
             $year1 = $obj->value[1];
             $datetime0 = new Datetime();
             $datetime0->modify('-' . $year0 . ' year');
             $obj->value[0] = $datetime0->format('Y-m-d 00:00:00');
             $datetime1 = new Datetime();
             $datetime1->modify('-' . $year1 . ' year');
             $obj->value[1] = $datetime1->format('Y-m-d 23:59:59');
         } else {
             $value0 = new JDate($obj->value[0]);
             $obj->value[0] = $value0->format('Y-m-d 00:00:00');
             $value1 = new JDate($obj->value[1]);
             $obj->value[1] = $value1->format('Y-m-d 23:59:59');
         }
     }
     if ($obj->condition == 'equal') {
         // equal to an age means the birthyear range is 1 year
         // so we make it become a range
         $obj->condition = 'between';
         if ($is_age) {
             $age = $obj->value;
             unset($obj->value);
             $year0 = $age + 1;
             $year1 = $age;
             $datetime0 = new Datetime();
             $datetime0->modify('-' . $year0 . ' year');
             $obj->value[0] = $datetime0->format('Y-m-d 00:00:00');
             $datetime1 = new Datetime();
             $datetime1->modify('-' . $year1 . ' year');
             $obj->value[1] = $datetime1->format('Y-m-d 23:59:59');
         } else {
             $value0 = new JDate($obj->value);
             $value1 = new JDate($obj->value);
             unset($obj->value);
             $obj->value[0] = $value0->format('Y-m-d 00:00:00');
             $obj->value[1] = $value1->format('Y-m-d 23:59:59');
         }
     }
     if ($obj->condition == 'lessthanorequal') {
         if ($is_age) {
             $obj->condition = 'between';
             $year0 = $obj->value + 1;
             unset($obj->value);
             $datetime0 = new Datetime();
             $datetime0->modify('-' . $year0 . ' year');
             $obj->value[0] = $datetime0->format('Y-m-d 00:00:00');
             $datetime1 = new Datetime();
             $obj->value[1] = $datetime1->format('Y-m-d 23:59:59');
         } else {
             $obj->condition = 'lessthanorequal';
             $value0 = new JDate($obj->value);
             $obj->value = $value0->format('Y-m-d 23:59:59');
         }
     }
     if ($obj->condition == 'greaterthanorequal') {
         if ($is_age) {
             $obj->condition = 'lessthanorequal';
             //the datetime logic is inversed
             $age = $obj->value;
             unset($obj->value);
             $year0 = $age;
             $datetime0 = new Datetime();
             $datetime0->modify('-' . $year0 . ' year');
             $obj->value = $datetime0->format('Y-m-d 00:00:00');
         } else {
             $obj->condition = 'between';
             $value0 = new JDate($obj->value);
             unset($obj->value);
             $obj->value[0] = $value0->format('Y-m-d 00:00:00');
             $value1 = new JDate();
             $obj->value[1] = $value1->format('Y-m-d 23:59:59');
         }
     }
     // correct the date order
     if (is_array($obj->value) && $obj->value[1] < $obj->value[0]) {
         $obj->value = array_reverse($obj->value);
     }
 }
Ejemplo n.º 22
0
 function admin_approuve_delete_trade($id_pool, $id_saison, $periode, $id_trade, $approuve_delete, $id_gerant, $poolName)
 {
     if ($this->isTodayFisrtDayOfAPeriod($id_pool, $id_saison)) {
         $table = "joueurs_pool_1st_day";
     } else {
         $table = "joueurs_pool";
     }
     if ($approuve_delete == "supprimer") {
         $subject = "{$poolName} - Transaction annulée...";
         $body = "La transaction avec {$nickname_gerant2} qui était sous approbation a été annulée par le commissaire.";
         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_trade, $periode, "admin_cancel_trade", $subject, $body);
         $query = "delete from trade\n                         where id_pool = {$id_pool}\n                               and saison_id = {$id_saison}\n                               and id = {$id_trade}";
         mysql_query($query, $this->handle);
         if (mysql_affected_rows() > 0) {
             $this->dbLog($id_pool, $id_gerant, "admin", $query);
         }
     } else {
         // envoi d'un email à tous les participants du pool avant de faire le switch des joueurs/picks pour avoir
         // la bonne information dans le email...
         $this->envoi_email_acceptProposition($id_pool, $id_saison, $id_trade, $periode, "admin_approuve_trade");
         $query = "select * from trade\n                         where id_pool = {$id_pool}\n                               and saison_id = {$id_saison}\n                               and id = {$id_trade}";
         $resultID = mysql_query($query, $this->handle);
         $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
         mysql_free_result($resultID);
         $id_gerant1 = $data["id_gerant1"];
         $id_gerant2 = $data["id_gerant2"];
         $liste_joueurs_gerant1 = $data["liste_joueurs_gerant1"];
         $liste_joueurs_gerant2 = $data["liste_joueurs_gerant2"];
         $liste_picks_gerant1 = $data['liste_picks_gerant1'];
         $liste_picks_gerant2 = $data['liste_picks_gerant2'];
         $periode_activation = $data["periode_activation"];
         $trade_approuve = $data["approuve"];
         $gerant1A = $this->getGerantProfil($id_pool, $id_gerant1, $id_saison);
         $gerant2A = $this->getGerantProfil($id_pool, $id_gerant2, $id_saison);
         // il ne faut pas faire le trade 2 fois... ça arrive quand F5 est appuyé
         // immmédiatement après avoir approuvé un échange
         if ($trade_approuve == "Y") {
             return;
         }
         // on met le champ 'approuve' à Y de la table trade
         $query = "update trade set approuve='Y'\n                         where id_pool = {$id_pool}\n                               and saison_id = {$id_saison}\n                               and id = {$id_trade}";
         mysql_query($query, $this->handle);
         if (mysql_affected_rows() > 0) {
             $this->dbLog($id_pool, $id_gerant, "admin_approuve_delete_trade", $query);
         }
         // On détruit toutes les autres propositions d'échange des 2 gérants qui contiennent
         // un des joueurs/picks impliqués dans l'échange...
         //$liste_joueurs_gerant1A = explode(":",$liste_joueurs_gerant1);
         $propositions1A = $this->getTradePropositions($id_pool, $id_gerant1, $id_saison);
         foreach ($propositions1A as $proposition) {
             $propositionA = explode(";", $proposition);
             $id_prop = $propositionA[0];
             $id_gerant1_prop = $propositionA[1];
             $liste_joueurs_gerant1_prop = $propositionA[2];
             $id_gerant2_prop = $propositionA[3];
             $liste_joueurs_gerant2_prop = $propositionA[4];
             $liste_picks_gerant1_prop = $propositionA[13];
             $liste_picks_gerant2_prop = $propositionA[14];
             if ($id_prop == $id_proposition) {
                 continue;
             }
             if ($id_gerant1_prop == $id_gerant1) {
                 $liste_joueurs_gerant1_propA = explode(":", $liste_joueurs_gerant1_prop);
                 foreach ($liste_joueurs_gerant1_propA as $id_player) {
                     if ($id_player == "") {
                         continue;
                     }
                     if (array_search($id_player, $liste_joueurs_gerant1A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
                 $liste_picks_gerant1_propA = explode(":", $liste_picks_gerant1_prop);
                 foreach ($liste_picks_gerant1_propA as $id_pick) {
                     if ($id_pick == "") {
                         continue;
                     }
                     if (array_search($id_pick, $liste_picks_gerant1A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
             } else {
                 $liste_joueurs_gerant2_propA = explode(":", $liste_joueurs_gerant2_prop);
                 foreach ($liste_joueurs_gerant2_propA as $id_player) {
                     if ($id_player == "") {
                         continue;
                     }
                     if (array_search($id_player, $liste_joueurs_gerant1A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
                 $liste_picks_gerant2_propA = explode(":", $liste_picks_gerant2_prop);
                 foreach ($liste_picks_gerant2_propA as $id_pick) {
                     if ($id_pick == "") {
                         continue;
                     }
                     if (array_search($id_pick, $liste_picks_gerant1A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
             }
         }
         //$liste_joueurs_gerant2A = explode(":",$liste_joueurs_gerant2);
         $propositions2A = $this->getTradePropositions($id_pool, $id_gerant2, $id_saison);
         foreach ($propositions2A as $proposition) {
             $propositionA = explode(";", $proposition);
             $id_prop = $propositionA[0];
             $id_gerant1_prop = $propositionA[1];
             $liste_joueurs_gerant1_prop = $propositionA[2];
             $id_gerant2_prop = $propositionA[3];
             $liste_joueurs_gerant2_prop = $propositionA[4];
             $liste_picks_gerant1_prop = $propositionA[13];
             $liste_picks_gerant2_prop = $propositionA[14];
             if ($id_prop == $id_proposition) {
                 continue;
             }
             if ($id_gerant1_prop == $id_gerant2) {
                 $liste_joueurs_gerant1_propA = explode(":", $liste_joueurs_gerant1_prop);
                 foreach ($liste_joueurs_gerant1_propA as $id_player) {
                     if ($id_player == "") {
                         continue;
                     }
                     if (array_search($id_player, $liste_joueurs_gerant2A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
                 $liste_picks_gerant1_propA = explode(":", $liste_picks_gerant1_prop);
                 foreach ($liste_picks_gerant1_propA as $id_pick) {
                     if ($id_pick == "") {
                         continue;
                     }
                     if (array_search($id_pick, $liste_picks_gerant2A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
             } else {
                 $liste_joueurs_gerant2_propA = explode(":", $liste_joueurs_gerant2_prop);
                 foreach ($liste_joueurs_gerant2_propA as $id_player) {
                     if ($id_player == "") {
                         continue;
                     }
                     if (array_search($id_player, $liste_joueurs_gerant2A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
                 $liste_picks_gerant2_propA = explode(":", $liste_picks_gerant2_prop);
                 foreach ($liste_picks_gerant2_propA as $id_pick) {
                     if ($id_pick == "") {
                         continue;
                     }
                     if (array_search($id_pick, $liste_picks_gerant2A) !== FALSE) {
                         // envoi d'un email aux 2 gérants de l'échange
                         $this->envoi_email_cancelProposition($id_pool, $id_saison, $id_prop, $periode);
                         $query = "update trade_proposition set gerant1_accepte='N',gerant2_accepte='N'\n                                             WHERE id_pool = {$id_pool} AND id = {$id_prop} AND saison_id = {$id_saison}";
                         $resultID = mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                         break;
                     }
                 }
             }
         }
         $liste_joueurs_gerant1A = explode(":", $liste_joueurs_gerant1);
         $liste_joueurs_gerant2A = explode(":", $liste_joueurs_gerant2);
         $liste_picks_gerant1A = explode(":", $liste_picks_gerant1);
         $liste_picks_gerant2A = explode(":", $liste_picks_gerant2);
         // écriture de l'échange dans la table des news
         $news = "<b><i><u>BREAKING NEWS!!</u></i></b><br> <b>" . $gerant1A["nickname"] . "</b> échange";
         foreach ($liste_joueurs_gerant1A as $id_player) {
             if ($id_player == "") {
                 continue;
             }
             $playerInfoA = $this->getPlayerInfoForBallotage($id_player, $id_saison, $id_pool);
             $first_name = $playerInfoA["first_name"];
             $last_name = $playerInfoA["last_name"];
             $abbr = $playerInfoA["abbr"];
             $points = $playerInfoA["points"];
             $pos = $playerInfoA["pos"];
             if ($pos == "TM") {
                 $news .= " {$last_name} (l'équipe) ({$points} pts),";
             } else {
                 $news .= " {$first_name} {$last_name} - {$abbr} ({$points} pts),";
             }
         }
         foreach ($liste_picks_gerant1A as $id_pick) {
             if ($id_pick == "") {
                 continue;
             }
             $q = "select a.pick_no,a.owner_ori,b.real_name_abrege\n                          from trade_draftPicks_gerant a, accounts b\n                          where\n                              a.id = {$id_pick}\n                              and a.owner_ori = b.id";
             $data = DB::dbSelect($q);
             $data = $data[0];
             $pick_no = $data['pick_no'];
             $pick_owner_ori = $data['owner_ori'];
             $pick_owner_ori_name = $data['real_name_abrege'];
             switch ($pick_no) {
                 case 1:
                     $news .= " choix de 1ère ronde";
                     break;
                 case 2:
                     $news .= " choix de 2e ronde";
                     break;
                 case 3:
                     $news .= " choix de 3e ronde";
                     break;
                 case 4:
                     $news .= " choix de 4e ronde";
                     break;
                 case 5:
                     $news .= " choix de 5e ronde";
                     break;
                 case 6:
                     $news .= " choix de 6e ronde";
                     break;
                 case 7:
                     $news .= " choix de 7e ronde";
                     break;
             }
             if ($pick_owner_ori != $id_gerant1) {
                 $news .= " (choix de {$pick_owner_ori_name}),";
             } else {
                 $news .= ",";
             }
         }
         $news = substr($news, 0, strlen($news) - 1);
         $news .= " à <b>" . $gerant2A["nickname"] . "</b> en retour de";
         foreach ($liste_joueurs_gerant2A as $id_player) {
             if ($id_player == "") {
                 continue;
             }
             $playerInfoA = $this->getPlayerInfoForBallotage($id_player, $id_saison, $id_pool);
             $first_name = $playerInfoA["first_name"];
             $last_name = $playerInfoA["last_name"];
             $abbr = $playerInfoA["abbr"];
             $points = $playerInfoA["points"];
             $pos = $playerInfoA["pos"];
             if ($pos == "TM") {
                 $news .= " {$last_name} (l'équipe) ({$points} pts),";
             } else {
                 $news .= " {$first_name} {$last_name} - {$abbr} ({$points} pts),";
             }
         }
         foreach ($liste_picks_gerant2A as $id_pick) {
             if ($id_pick == "") {
                 continue;
             }
             $q = "select a.pick_no,a.owner_ori,b.real_name_abrege\n                          from trade_draftPicks_gerant a, accounts b\n                          where\n                              a.id = {$id_pick}\n                              and a.owner_ori = b.id";
             $data = DB::dbSelect($q);
             $data = $data[0];
             $pick_no = $data['pick_no'];
             $pick_owner_ori = $data['owner_ori'];
             $pick_owner_ori_name = $data['real_name_abrege'];
             switch ($pick_no) {
                 case 1:
                     $news .= " choix de 1ère ronde";
                     break;
                 case 2:
                     $news .= " choix de 2e ronde";
                     break;
                 case 3:
                     $news .= " choix de 3e ronde";
                     break;
                 case 4:
                     $news .= " choix de 4e ronde";
                     break;
                 case 5:
                     $news .= " choix de 5e ronde";
                     break;
                 case 6:
                     $news .= " choix de 6e ronde";
                     break;
                 case 7:
                     $news .= " choix de 7e ronde";
                     break;
             }
             if ($pick_owner_ori != $id_gerant2) {
                 $news .= " (choix de {$pick_owner_ori_name}),";
             } else {
                 $news .= ",";
             }
         }
         $news = substr($news, 0, strlen($news) - 1);
         $_mydate = new Datetime(null, $this->timeZone);
         $_mydate->modify("+2 days");
         $date_fin = $_mydate->format('Y-m-d');
         $query = "INSERT INTO newsbar (id_pool,date_debut,date_fin,priority,text,saison_id)\n                    VALUES ({$id_pool},'{$this->today}',\"{$date_fin}\",20,\"{$news}\",{$id_saison})";
         $resultID = mysql_query($query, $this->handle);
         // si les joueurs échangés faisaient partis de la liste 'trading block', on l'enlève...
         foreach ($liste_joueurs_gerant1A as $id_player) {
             if ($id_player == "") {
                 continue;
             }
             $query = "update {$table} set trading_block='N'\n                              where id_pool = {$id_pool}\n                              and saison_id = {$id_saison}\n                              and gerant = {$id_gerant1}\n                              and id_player = {$id_player}\n                              and periode > {$periode}";
             mysql_query($query, $this->handle);
             if (mysql_affected_rows() > 0) {
                 $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
             }
         }
         foreach ($liste_joueurs_gerant2A as $id_player) {
             if ($id_player == "") {
                 continue;
             }
             $query = "update {$table} set trading_block='N'\n                              where id_pool = {$id_pool}\n                              and saison_id = {$id_saison}\n                              and gerant = {$id_gerant2}\n                              and id_player = {$id_player}\n                              and periode > {$periode}";
             mysql_query($query, $this->handle);
             if (mysql_affected_rows() > 0) {
                 $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
             }
         }
         // SWICH DES JOUEURS
         $query = "select trade_howto_switch_players,date_debut_saison from configPool\n                         where id_pool = {$id_pool}\n                              and saison_id = {$id_saison}";
         $resultID = mysql_query($query, $this->handle);
         $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
         mysql_free_result($resultID);
         $trade_howto_switch_players = $data["trade_howto_switch_players"];
         $date_debut_saison = $data["date_debut_saison"];
         if ($trade_howto_switch_players == "rang") {
             // création des listes pour faire le swith après...
             foreach ($liste_joueurs_gerant1A as $id_player) {
                 if ($id_player == "") {
                     continue;
                 }
                 if ($OR == "") {
                     $OR = "id_player = {$id_player}";
                 } else {
                     $OR .= " OR id_player = {$id_player}";
                 }
             }
             $query = "SELECT id_player,rank FROM {$table}\n                              WHERE id_pool = {$id_pool}\n                              AND gerant = {$id_gerant1}\n                              AND periode = {$periode}\n                              AND saison_id = {$id_saison}\n                              AND ({$OR})\n                              ORDER BY rank ASC;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $liste_triee_joueurs_gerant1A[] = $id_player;
             }
             mysql_free_result($resultID);
             foreach ($liste_joueurs_gerant2A as $id_player) {
                 if ($id_player == "") {
                     continue;
                 }
                 if ($OR == "") {
                     $OR = "id_player = {$id_player}";
                 } else {
                     $OR .= " OR id_player = {$id_player}";
                 }
             }
             $query = "SELECT id_player,rank FROM {$table}\n                              WHERE id_pool = {$id_pool}\n                              AND gerant = {$id_gerant2}\n                              AND periode = {$periode}\n                              AND saison_id = {$id_saison}\n                              AND ({$OR})\n                              ORDER BY rank ASC;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $liste_triee_joueurs_gerant2A[] = $id_player;
             }
             mysql_free_result($resultID);
             //$nbre_per = $this->getNombrePeriodes($id_pool,$id_saison);
             $nbre_joueurs = count($liste_joueurs_gerant1A) - 1;
             for ($i = 0; $i < $nbre_joueurs; $i++) {
                 // est-ce que le joueur est sur la liste IR?
                 $query = "SELECT rank,IR FROM {$table}\n\t\t               \t\tWHERE id_pool = {$id_pool}\n\t\t               \t\t     AND saison_id = {$id_saison}\n\t\t               \t\t     AND gerant = {$id_gerant1}\n\t\t               \t\t\tAND periode = {$periode_activation}\n\t\t               \t\t\tAND id_player = {$liste_triee_joueurs_gerant1A[$i]}";
                 $resultID = mysql_query($query, $this->handle);
                 $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                 mysql_free_result($resultID);
                 $infoJoueur1['rank'] = $data["rank"];
                 $infoJoueur1['IR'] = $data["IR"];
                 // est-ce que le joueur est sur la liste IR?
                 $query = "SELECT rank,IR FROM {$table}\n\t\t               \t\tWHERE id_pool = {$id_pool}\n\t\t               \t\t     AND saison_id = {$id_saison}\n\t\t               \t\t     AND gerant = {$id_gerant2}\n\t\t               \t\t\tAND periode = {$periode_activation}\n\t\t               \t\t\tAND id_player = {$liste_triee_joueurs_gerant2A[$i]}";
                 $resultID = mysql_query($query, $this->handle);
                 $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                 mysql_free_result($resultID);
                 $infoJoueur2['rank'] = $data["rank"];
                 $infoJoueur2['IR'] = $data["IR"];
                 // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                 $query = "SELECT IR FROM {$table}\n\t\t               \t\tWHERE id_pool = {$id_pool}\n\t\t               \t\t     AND saison_id = {$id_saison}\n\t\t               \t\t     AND gerant = {$id_gerant1}\n\t\t               \t\t\tAND periode = {$periode_activation}\n\t\t               \t\t\tAND rank = {$infoJoueur1['rank']}\n\t\t               \t\t\tAND IR = 'Y'";
                 $resultID = mysql_query($query, $this->handle);
                 $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                 mysql_free_result($resultID);
                 $infoJoueur1['remplacant_IR'] = $data["IR"];
                 // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                 $query = "SELECT IR FROM {$table}\n\t\t               \t\tWHERE id_pool = {$id_pool}\n\t\t               \t\t     AND saison_id = {$id_saison}\n\t\t               \t\t     AND gerant = {$id_gerant2}\n\t\t               \t\t\tAND periode = {$periode_activation}\n\t\t               \t\t\tAND rank = {$infoJoueur2['rank']}\n\t\t               \t\t\tAND IR = 'Y'";
                 $resultID = mysql_query($query, $this->handle);
                 $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                 mysql_free_result($resultID);
                 $infoJoueur2['remplacant_IR'] = $data["IR"];
                 $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_gerant1A[$i]}\n\t\t               \t\tWHERE id_pool = {$id_pool}\n\t\t               \t\tAND periode >= {$periode_activation}\n\t\t               \t\tAND gerant = {$id_gerant2}\n\t\t               \t\tAND rank = {$infoJoueur2['rank']}\n\t\t               \t\tAND saison_id = {$id_saison}\n\t\t               \t\tAND IR = '{$infoJoueur2['IR']}'";
                 mysql_query($query, $this->handle);
                 if (mysql_affected_rows() > 0) {
                     $this->dbLog($id_pool, $id_gerant, "admin_approuve_delete_trade", $query);
                 }
                 $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_gerant2A[$i]}\n\t\t               \t\tWHERE id_pool = {$id_pool}\n\t\t               \t\tAND periode >= {$periode_activation}\n\t\t               \t\tAND gerant = {$id_gerant1}\n\t\t               \t\tAND rank = {$infoJoueur1['rank']}\n\t\t               \t\tAND saison_id = {$id_saison}\n\t\t               \t\tAND IR = '{$infoJoueur1['IR']}'";
                 mysql_query($query, $this->handle);
                 if (mysql_affected_rows() > 0) {
                     $this->dbLog($id_pool, $id_gerant, "admin_approuve_delete_trade", $query);
                 }
                 // si le joueur est sur la liste IR, il faut modifier l'entrée dans la table
                 // liste_IR avec le joueur qui prend sa place
                 if ($infoJoueur1['IR'] == "Y") {
                     $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_gerant2A[$i]}\n                                        where id_pool = {$id_pool}\n                                        and id_gerant = {$id_gerant1}\n                                        and id_player_IR = {$liste_triee_joueurs_gerant1A[$i]}\n                                        and date_fin = '2099-12-31'\n                                        and rank_player_IR = {$infoJoueur1['rank']}";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "admin_approuve_delete_trade", $query);
                     }
                 }
                 if ($infoJoueur2['IR'] == "Y") {
                     $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_gerant1A[$i]}\n                                        where id_pool = {$id_pool}\n                                        and id_gerant = {$id_gerant2}\n                                        and id_player_IR = {$liste_triee_joueurs_gerant2A[$i]}\n                                        and date_fin = '2099-12-31'\n                                        and rank_player_IR = {$infoJoueur2['rank']}";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "admin_approuve_delete_trade", $query);
                     }
                 }
                 // si le joueur est en remplacement d'un joueur blessé (liste IR), il faut modifier l'entrée dans la table
                 // liste_IR
                 if ($infoJoueur1['remplacant_IR'] == "Y") {
                     $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_gerant2A[$i]}\n                                        where id_pool = {$id_pool}\n                                        and id_gerant = {$id_gerant1}\n                                        and id_player_remplacement = {$liste_triee_joueurs_gerant1A[$i]}\n                                        and date_fin = '2099-12-31'\n                                        and rank_player_IR = {$infoJoueur1['rank']}";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                 }
                 if ($infoJoueur2['remplacant_IR'] == "Y") {
                     $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_gerant1A[$i]}\n                                        where id_pool = {$id_pool}\n                                        and id_gerant = {$id_gerant2}\n                                        and id_player_remplacement = {$liste_triee_joueurs_gerant2A[$i]}\n                                        and date_fin = '2099-12-31'\n                                        and rank_player_IR = {$infoJoueur2['rank']}";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                 }
             }
         } else {
             // création des listes pour faire le swith après...
             $liste_joueurs_gerant1_select = "";
             foreach ($liste_joueurs_gerant1A as $id_player) {
                 if ($id_player == "") {
                     continue;
                 }
                 if ($liste_joueurs_gerant1_select == "") {
                     $liste_joueurs_gerant1_select = $id_player;
                 } else {
                     $liste_joueurs_gerant1_select .= ",{$id_player}";
                 }
             }
             $liste_joueurs_gerant2_select = "";
             foreach ($liste_joueurs_gerant2A as $id_player) {
                 if ($id_player == "") {
                     continue;
                 }
                 if ($liste_joueurs_gerant2_select == "") {
                     $liste_joueurs_gerant2_select = $id_player;
                 } else {
                     $liste_joueurs_gerant2_select .= ",{$id_player}";
                 }
             }
             /**********
              *** BUG ***
              *** Quand un joueur n'a pas joué de la saison et qu'il est échangé, il n'y a aucune entrée ds la table
              *** joueurs_pts pour ce joueur, ce qui fait que son id n'apparaitra pas dans les listes des switchs
              *** des joueurs. Pour régler ce problème, je vais faire une entrée bidon pour chaque joueur échangé
              *** dans la table joueurs_pts avec la date 2099-12-31 et 0 pts. Ainsi, la logique du tri demeure intacte
              *** puisque tous les joueurs ont +0 pour les pts et +1 pour les pj...
              ***********/
             foreach ($liste_joueurs_gerant1A as $this_id_player) {
                 $query = "replace into joueurs_pts (saison_id,id_player,date,points)\n                                         values ({$id_saison},{$this_id_player},'2099-12-31',0)";
                 mysql_query($query, $this->handle);
                 if (mysql_affected_rows() > 0) {
                     $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                 }
             }
             foreach ($liste_joueurs_gerant2A as $this_id_player) {
                 $query = "replace into joueurs_pts (saison_id,id_player,date,points)\n                                         values ({$id_saison},{$this_id_player},'2099-12-31',0)";
                 mysql_query($query, $this->handle);
                 if (mysql_affected_rows() > 0) {
                     $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                 }
             }
             /*****************
              *** GRAND CLUB ***
              *****************/
             // Gérant 1
             // il faut le faire par position (TM, G, D et F)...
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant1_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant1}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant1_select})\n                                   and c.pos = 'TM'\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_TM_gerant1A[] = $id_player;
                 $joueurs_rank_gerant1A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant1_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant1}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant1_select})\n                                   and c.pos = 'G'\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_G_gerant1A[] = $id_player;
                 $joueurs_rank_gerant1A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant1_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant1}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant1_select})\n                                   and c.pos = 'D'\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_D_gerant1A[] = $id_player;
                 $joueurs_rank_gerant1A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant1_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant1}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant1_select})\n                                   and c.pos not in ('G','D','TM')\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_A_gerant1A[] = $id_player;
                 $joueurs_rank_gerant1A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             // Gérant 2
             // il faut le faire par position (TM, G, D et F)...
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant2_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant2}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant2_select})\n                                   and c.pos = 'TM'\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_TM_gerant2A[] = $id_player;
                 $joueurs_rank_gerant2A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant2_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant2}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant2_select})\n                                   and c.pos = 'G'\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_G_gerant2A[] = $id_player;
                 $joueurs_rank_gerant2A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant2_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant2}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant2_select})\n                                   and c.pos = 'D'\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_D_gerant2A[] = $id_player;
                 $joueurs_rank_gerant2A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant2_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant2}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'Y'\n                                   AND a.id_player in ({$liste_joueurs_gerant2_select})\n                                   and c.pos not in ('G','D','TM')\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_A_gerant2A[] = $id_player;
                 $joueurs_rank_gerant2A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             // SWITCH DES JOUEURS, PAR POSITION...
             // équipes
             $nbre_items = count($liste_triee_joueurs_TM_gerant1A);
             if ($nbre_items > 0) {
                 for ($i = 0; $i < $nbre_items; $i++) {
                     $infoJoueur1['rank'] = $joueurs_rank_gerant1A[$liste_triee_joueurs_TM_gerant1A[$i]];
                     $infoJoueur2['rank'] = $joueurs_rank_gerant2A[$liste_triee_joueurs_TM_gerant2A[$i]];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_TM_gerant1A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['IR'] = $data["IR"];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_TM_gerant2A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['remplacant_IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['remplacant_IR'] = $data["IR"];
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_TM_gerant1A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant2}\n\t\t                    \t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur2['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_TM_gerant2A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant1}\n\t\t                    \t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur1['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     // si le joueur est sur la liste IR, il faut modifier l'entrée dans la table
                     // liste_IR avec le joueur qui prend sa place
                     if ($infoJoueur1['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_TM_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_IR = {$liste_triee_joueurs_TM_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_TM_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_IR = {$liste_triee_joueurs_TM_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     // si le joueur est en remplacement d'un joueur blessé (liste IR), il faut modifier l'entrée dans la table
                     // liste_IR
                     if ($infoJoueur1['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_TM_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_remplacement = {$liste_triee_joueurs_TM_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_TM_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_remplacement = {$liste_triee_joueurs_TM_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                 }
             }
             // gardiens
             $nbre_items = count($liste_triee_joueurs_G_gerant1A);
             if ($nbre_items > 0) {
                 for ($i = 0; $i < $nbre_items; $i++) {
                     $infoJoueur1['rank'] = $joueurs_rank_gerant1A[$liste_triee_joueurs_G_gerant1A[$i]];
                     $infoJoueur2['rank'] = $joueurs_rank_gerant2A[$liste_triee_joueurs_G_gerant2A[$i]];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_G_gerant1A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['IR'] = $data["IR"];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_G_gerant2A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['remplacant_IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['remplacant_IR'] = $data["IR"];
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_G_gerant1A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant2}\n\t\t                    \t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur2['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_G_gerant2A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant1}\n\t\t                    \t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur1['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     // si le joueur est sur la liste IR, il faut modifier l'entrée dans la table
                     // liste_IR avec le joueur qui prend sa place
                     if ($infoJoueur1['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_G_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_IR = {$liste_triee_joueurs_G_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_G_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_IR = {$liste_triee_joueurs_G_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     // si le joueur est en remplacement d'un joueur blessé (liste IR), il faut modifier l'entrée dans la table
                     // liste_IR
                     if ($infoJoueur1['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_G_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_remplacement = {$liste_triee_joueurs_G_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_G_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_remplacement = {$liste_triee_joueurs_G_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                 }
             }
             // défenseurs
             $nbre_items = count($liste_triee_joueurs_D_gerant1A);
             if ($nbre_items > 0) {
                 for ($i = 0; $i < $nbre_items; $i++) {
                     $infoJoueur1['rank'] = $joueurs_rank_gerant1A[$liste_triee_joueurs_D_gerant1A[$i]];
                     $infoJoueur2['rank'] = $joueurs_rank_gerant2A[$liste_triee_joueurs_D_gerant2A[$i]];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_D_gerant1A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['IR'] = $data["IR"];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_D_gerant2A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['remplacant_IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['remplacant_IR'] = $data["IR"];
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_D_gerant1A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant2}\n\t\t                    \t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur2['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_D_gerant2A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant1}\n\t\t                    \t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur1['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     // si le joueur est sur la liste IR, il faut modifier l'entrée dans la table
                     // liste_IR avec le joueur qui prend sa place
                     if ($infoJoueur1['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_D_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_IR = {$liste_triee_joueurs_D_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_D_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_IR = {$liste_triee_joueurs_D_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     // si le joueur est en remplacement d'un joueur blessé (liste IR), il faut modifier l'entrée dans la table
                     // liste_IR
                     if ($infoJoueur1['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_D_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_remplacement = {$liste_triee_joueurs_D_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_D_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_remplacement = {$liste_triee_joueurs_D_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                 }
             }
             // avants
             $nbre_items = count($liste_triee_joueurs_A_gerant1A);
             if ($nbre_items > 0) {
                 for ($i = 0; $i < $nbre_items; $i++) {
                     $infoJoueur1['rank'] = $joueurs_rank_gerant1A[$liste_triee_joueurs_A_gerant1A[$i]];
                     $infoJoueur2['rank'] = $joueurs_rank_gerant2A[$liste_triee_joueurs_A_gerant2A[$i]];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_A_gerant1A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['IR'] = $data["IR"];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_A_gerant2A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['remplacant_IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['remplacant_IR'] = $data["IR"];
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_A_gerant1A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant2}\n\t\t                    \t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur2['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_A_gerant2A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant1}\n\t\t                    \t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur1['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     // si le joueur est sur la liste IR, il faut modifier l'entrée dans la table
                     // liste_IR avec le joueur qui prend sa place
                     if ($infoJoueur1['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_A_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_IR = {$liste_triee_joueurs_A_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_A_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_IR = {$liste_triee_joueurs_A_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     // si le joueur est en remplacement d'un joueur blessé (liste IR), il faut modifier l'entrée dans la table
                     // liste_IR
                     if ($infoJoueur1['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_A_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_remplacement = {$liste_triee_joueurs_A_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_A_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_remplacement = {$liste_triee_joueurs_A_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                 }
             }
             /*****************
              *** CLUB ÉCOLE ***
              *****************/
             // Le club école est différent, car n'importe quel joueur peut être échangé
             // pour un autre: pas besoin d'être de la même position...
             unset($joueurs_rank_gerant1A, $joueurs_rank_gerant2A);
             unset($liste_triee_joueurs_TM_gerant1A, $liste_triee_joueurs_TM_gerant2A);
             unset($liste_triee_joueurs_G_gerant1A, $liste_triee_joueurs_G_gerant2A);
             unset($liste_triee_joueurs_D_gerant1A, $liste_triee_joueurs_D_gerant2A);
             unset($liste_triee_joueurs_A_gerant1A, $liste_triee_joueurs_A_gerant2A);
             // Gérant 1
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant1_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant1}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'N'\n                                   AND a.id_player in ({$liste_joueurs_gerant1_select})\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_gerant1A[] = $id_player;
                 $joueurs_rank_gerant1A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             // Gérant 2
             // il faut le faire par position (TM, G, D et F)...
             $query = "SELECT a.id_player,a.rank,b.pts,b.pj\n                              FROM {$table} a,\n                                   (select id_player,sum(points) pts,count(*) pj\n                                    from joueurs_pts\n                                    where saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant2_select})\n                                        and date >= '{$date_debut_saison}'\n                                    group by id_player\n                                   ) b,\n                                   nhl_players c\n                              WHERE a.id_player = b.id_player\n                                   and a.id_player = c.id\n                                   and a.id_pool = {$id_pool}\n                                   AND a.gerant = {$id_gerant2}\n                                   AND a.periode = {$periode}\n                                   AND a.saison_id = {$id_saison}\n                                   and a.grand_club = 'N'\n                                   AND a.id_player in ({$liste_joueurs_gerant2_select})\n                                   and c.date_expiration = '2099-12-31'\n                              ORDER BY b.pts desc,b.pj asc;";
             $resultID = mysql_query($query, $this->handle);
             while ($data = mysql_fetch_array($resultID, MYSQL_ASSOC)) {
                 $id_player = $data["id_player"];
                 $rank = $data["rank"];
                 $liste_triee_joueurs_gerant2A[] = $id_player;
                 $joueurs_rank_gerant2A[$id_player] = $rank;
             }
             mysql_free_result($resultID);
             // SWITCH DES JOUEURS, PAR POSITION...
             $nbre_items = count($liste_triee_joueurs_gerant1A);
             if ($nbre_items > 0) {
                 for ($i = 0; $i < $nbre_items; $i++) {
                     $infoJoueur1['rank'] = $joueurs_rank_gerant1A[$liste_triee_joueurs_gerant1A[$i]];
                     $infoJoueur2['rank'] = $joueurs_rank_gerant2A[$liste_triee_joueurs_gerant2A[$i]];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_gerant1A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['IR'] = $data["IR"];
                     // est-ce que le joueur est sur la liste IR?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND id_player = {$liste_triee_joueurs_gerant2A[$i]}";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant1}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur1['remplacant_IR'] = $data["IR"];
                     // est-ce que le joueur est en remplacement d'un joueur blessé (liste IR)?
                     $query = "SELECT IR FROM {$table}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\t     AND saison_id = {$id_saison}\n\t\t                    \t\t     AND gerant = {$id_gerant2}\n\t\t                    \t\t\tAND periode = {$periode_activation}\n\t\t                    \t\t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\t\tAND IR = 'Y'";
                     $resultID = mysql_query($query, $this->handle);
                     $data = mysql_fetch_array($resultID, MYSQL_ASSOC);
                     mysql_free_result($resultID);
                     $infoJoueur2['remplacant_IR'] = $data["IR"];
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_gerant1A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant2}\n\t\t                    \t\tAND rank = {$infoJoueur2['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur2['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     $query = "UPDATE {$table} SET id_player={$liste_triee_joueurs_gerant2A[$i]}\n\t\t                    \t\tWHERE id_pool = {$id_pool}\n\t\t                    \t\tAND periode >= {$periode_activation}\n\t\t                    \t\tAND gerant = {$id_gerant1}\n\t\t                    \t\tAND rank = {$infoJoueur1['rank']}\n\t\t                    \t\tAND saison_id = {$id_saison}\n\t\t                    \t\tAND IR = '{$infoJoueur1['IR']}'";
                     mysql_query($query, $this->handle);
                     if (mysql_affected_rows() > 0) {
                         $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                     }
                     // si le joueur est sur la liste IR, il faut modifier l'entrée dans la table
                     // liste_IR avec le joueur qui prend sa place
                     if ($infoJoueur1['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_IR = {$liste_triee_joueurs_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['IR'] == "Y") {
                         $query = "update liste_IR set id_player_IR={$liste_triee_joueurs_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_IR = {$liste_triee_joueurs_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     // si le joueur est en remplacement d'un joueur blessé (liste IR), il faut modifier l'entrée dans la table
                     // liste_IR
                     if ($infoJoueur1['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_gerant2A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant1}\n                                             and id_player_remplacement = {$liste_triee_joueurs_gerant1A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur1['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                     if ($infoJoueur2['remplacant_IR'] == "Y") {
                         $query = "update liste_IR set id_player_remplacement={$liste_triee_joueurs_gerant1A[$i]}\n                                             where id_pool = {$id_pool}\n                                             and id_gerant = {$id_gerant2}\n                                             and id_player_remplacement = {$liste_triee_joueurs_gerant2A[$i]}\n                                             and date_fin = '2099-12-31'\n                                             and rank_player_IR = {$infoJoueur2['rank']}";
                         mysql_query($query, $this->handle);
                         if (mysql_affected_rows() > 0) {
                             $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
                         }
                     }
                 }
             }
             // Il faut enlever les entrées dans la table joueurs_pts qui ont comme date 2099-12-31...
             $query = "delete from joueurs_pts where date = '2099-12-31'\n                                        and saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant1_select})";
             mysql_query($query, $this->handle);
             if (mysql_affected_rows() > 0) {
                 $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
             }
             $query = "delete from joueurs_pts where date = '2099-12-31'\n                                        and saison_id = {$id_saison}\n                                        and id_player in ({$liste_joueurs_gerant2_select})";
             mysql_query($query, $this->handle);
             if (mysql_affected_rows() > 0) {
                 $this->dbLog($id_pool, $id_gerant, "tradePropositionAccept", $query);
             }
         }
         // SWITCH DES PCIKS
         foreach ($liste_picks_gerant1A as $id_pick) {
             $q = "update trade_draftPicks_gerant set owner={$id_gerant2}\n                          where id = {$id_pick}";
             DB::dbUpdate($q);
         }
         foreach ($liste_picks_gerant2A as $id_pick) {
             $q = "update trade_draftPicks_gerant set owner={$id_gerant1}\n                          where id = {$id_pick}";
             DB::dbUpdate($q);
         }
     }
 }
Ejemplo n.º 23
0
 public function testRouteRightTimeApplyWithtoutBasOrSbas()
 {
     $user = self::$DI['app']['manipulator.user']->createUser(uniqid('user_'), "test");
     $date = new \Datetime();
     $date->modify("-10 days");
     $dmin = $date->format(DATE_ATOM);
     $date->modify("+30 days");
     $dmax = $date->format(DATE_ATOM);
     self::$DI['client']->request('POST', '/admin/users/rights/time/apply/', ['dmin' => $dmin, 'dmax' => $dmax, 'limit' => 1, 'users' => $user->getId()]);
     $response = self::$DI['client']->getResponse();
     $this->assertEquals(400, $response->getStatusCode());
     self::$DI['app']['manipulator.user']->delete($user);
 }
Ejemplo n.º 24
0
<?php

$date = new Datetime('2016-01-24 23:59:59');
$date1 = new Datetime('2017-01-24 23:59:58');
//compare
$bool = $date > $date1;
var_dump($bool);
//modify
$date->modify('+ 2 day');
var_dump($date);
//diff
$diff = $date->diff($date1);
var_dump($diff);
Ejemplo n.º 25
0
 /**
  * @desc init dmin and dmax
  * @return <void>
  */
 protected function initDate()
 {
     $datetime = new Datetime();
     $this->dmax = $datetime->format('d-m-Y');
     $datetime->modify($this->periode);
     $this->dmin = $datetime->format('d-m-Y');
     return;
 }
Ejemplo n.º 26
0
 /**
  * log user in
  * @author Kydz 2015-06-14
  * @return sting user token
  */
 public function login()
 {
     $this->baseValidate();
     $user = User::where('u_mobile', '=', $this->u_mobile)->where('u_status', '=', 1)->first();
     if (!isset($user->u_id)) {
         throw new Exception("请求的用户不可用", 3002);
     }
     if (!Hash::check($this->u_password, $user->u_password)) {
         throw new Exception("密码错误", 3002);
     } else {
         $re = [];
         $re['token'] = $user->u_token;
         $now = new Datetime();
         $now->modify('+ 30 days');
         $re['expire'] = $now->format('Y-m-d H:i:s');
         $re['invite_code'] = $user->u_invite_code;
         $re['id'] = $user->u_id;
         $re['name'] = $user->u_name;
         $re['mobile'] = $user->u_mobile;
         $re['nickname'] = $user->u_nickname;
         $re['is_verified'] = $user->u_is_verified;
         $re['head_img'] = $user->getHeadImg();
         $re['biograph'] = $user->u_biograph;
         $school = DicSchool::find($user->u_school_id);
         if (empty($school)) {
             $re['city'] = null;
             $re['school'] = null;
         } else {
             $re['city'] = DicCity::where('c_id', '=', $school->t_city)->where('c_province_id', '=', $school->t_province)->first()->showInList();
             $re['school'] = $school->showInList();
         }
         $re['gender'] = $user->u_sex;
         $user->load('booths');
         $booths = null;
         if (!empty($user->booths)) {
             foreach ($user->booths as $key => $booth) {
                 $booths[] = $booth->showInLogin();
             }
         }
         $re['boohts'] = $booths;
         $re['import_type'] = 'phone';
         $user->save();
         return $re;
     }
 }