示例#1
0
 public function editAction()
 {
     $id = $this->_request->getParam('id');
     $form = new Form_Bukh();
     $request = $this->getRequest();
     if ($request->isPost()) {
         if ($form->isValid($this->_request->getPost())) {
             $lname = $this->_request->getParam('obog');
             $fname = $this->_request->getParam('ner');
             $date = $this->_request->getParam('date');
             $tsoldate = $this->_request->getParam('tsoldate');
             $sponsor = $this->_request->getParam('sponsor');
             $bukhchuud = new Model_DbTable_Bukh();
             $bukhchuud->update(array('lname' => $lname, 'fname' => $fname, 'date' => $date, 'tsoldate' => $tsoldate, 'sponsor' => $sponsor), 'id = ' . $id);
             $this->_redirect('bukhchuud/index');
         }
     }
     $bukhchuud = new Model_DbTable_Bukh();
     $res = $bukhchuud->fetchAll($bukhchuud->select()->where('id = ' . $id));
     foreach ($res as $val) {
         $form->obog->setValue($val["lname"]);
         $form->ner->setValue($val["fname"]);
         $form->date->setValue($val["date"]);
         $form->tsol->setValue($val["tsolid"]);
         $form->tsoldate->setValue($val["tsoldate"]);
         $form->aimag->setValue($val["aimagid"]);
         $form->sum->setValue($val["sumid"]);
         $form->sponsor->setValue($val["sponsor"]);
     }
     $form->add->setLabel("Засварлах");
     $form->setAction('../../edit/id/' . $id);
     $this->view->form = $form;
 }
示例#2
0
 public function ajaxdavaascoreAction()
 {
     $davaa_num = $this->_request->getParam('davaa_num');
     $fantasy_id = $this->_request->getParam('fantasy_id');
     $onoo = new Model_DbTable_Score();
     $ds = new Model_DbTable_Davaa();
     $dd = $ds->fetchAll($ds->select()->where('fantasy_id =' . $fantasy_id . ' AND davaa_num =' . $davaa_num));
     $barildaan = 0;
     foreach ($dd as $key => $value) {
         $barildaan = $value['barildaan_id'];
     }
     $onoolts = new Model_DbTable_Onoolt();
     $onoolt = $onoolts->fetchAll($onoolts->select()->where('barildaan_id =' . $barildaan));
     $bukhs = new Model_DbTable_Bukh();
     $tsols = new Model_DbTable_Tsol();
     $tsoluud = array();
     $tsol = $tsols->fetchAll($tsols->select());
     for ($i = 0; $i < 1000; $i++) {
         $tsoluud[$i] = 0;
     }
     foreach ($tsol as $key => $value) {
         $tsoluud[$value['id']] = $value['score'];
     }
     //Энд галуудын фантази оноог тооцоолно
     $davaagals = new Model_DbTable_Davaagal();
     $davaa = $davaagals->fetchAll($davaagals->select()->where('fantasy_id = ' . $fantasy_id . ' AND davaa_num = ' . $davaa_num));
     foreach ($davaa as $key => $val) {
         $bukh1_id = $val['bukh1_id'];
         $bukh2_id = $val['bukh2_id'];
         $bukh3_id = $val['bukh3_id'];
         $bukh4_id = $val['bukh4_id'];
         $bukh5_id = $val['bukh5_id'];
         $bukh6_id = $val['bukh6_id'];
         $bukh7_id = $val['bukh7_id'];
         $bukh8_id = $val['bukh8_id'];
         $bukh9_id = $val['bukh9_id'];
         $bukh10_id = $val['bukh10_id'];
         $galid = $val['gal_id'];
         $score = 0;
         $bukh1score = 0;
         $bukh2score = 0;
         $bukh3score = 0;
         $bukh4score = 0;
         $bukh5score = 0;
         $bukh6score = 0;
         $bukh7score = 0;
         $bukh8score = 0;
         $bukh9score = 0;
         $bukh10score = 0;
         foreach ($onoolt as $key => $on) {
             if ($on['bukh1_id'] == $bukh1_id || $on['bukh2_id'] == $bukh1_id) {
                 $bukh = $bukhs->fetchAll($bukhs->select()->where('id =' . $on['bukh1_id'] . ' OR id = ' . $on['bukh2_id']));
                 foreach ($bukh as $key => $bb) {
                     if ($bb['id'] == $on['bukh1_id']) {
                         $bukh1_tsolid = $bb['tsolid'];
                     } else {
                         $bukh2_tsolid = $bb['tsolid'];
                     }
                 }
                 if ($on['bukh1_id'] == $bukh1_id) {
                     if ($on['davsanbukh_id'] == $bukh1_id) {
                         $bukh1score += ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 20 + 1000;
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh1score -= ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 10 + 300;
                         }
                     }
                 } else {
                     if ($on['davsanbukh_id'] == $bukh1_id) {
                         $bukh1score += ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 20 + 1000;
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh1score -= ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 10 + 300;
                         }
                     }
                 }
             }
             if ($on['bukh1_id'] == $bukh2_id || $on['bukh2_id'] == $bukh2_id) {
                 $bukh = $bukhs->fetchAll($bukhs->select()->where('id =' . $on['bukh1_id'] . ' OR id = ' . $on['bukh2_id']));
                 foreach ($bukh as $key => $bb) {
                     if ($bb['id'] == $on['bukh1_id']) {
                         $bukh1_tsolid = $bb['tsolid'];
                     } else {
                         $bukh2_tsolid = $bb['tsolid'];
                     }
                 }
                 if ($on['bukh1_id'] == $bukh2_id) {
                     if ($on['davsanbukh_id'] == $bukh2_id) {
                         $bukh2score += ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh2score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh2score -= ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 10 + 300;
                         }
                     }
                 } else {
                     if ($on['davsanbukh_id'] == $bukh2_id) {
                         $bukh2score += ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh2score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh2score -= ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 10 + 300;
                         }
                     }
                 }
             }
             ////////////////////////////////////////////////////////////////////////////////////////
             if ($on['bukh1_id'] == $bukh3_id || $on['bukh2_id'] == $bukh3_id) {
                 $bukh = $bukhs->fetchAll($bukhs->select()->where('id =' . $on['bukh1_id'] . ' OR id = ' . $on['bukh2_id']));
                 foreach ($bukh as $key => $bb) {
                     if ($bb['id'] == $on['bukh1_id']) {
                         $bukh1_tsolid = $bb['tsolid'];
                     } else {
                         $bukh2_tsolid = $bb['tsolid'];
                     }
                 }
                 if ($on['bukh1_id'] == $bukh3_id) {
                     if ($on['davsanbukh_id'] == $bukh3_id) {
                         $bukh3score += ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh3score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh3score -= ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 10 + 300;
                         }
                     }
                 } else {
                     if ($on['davsanbukh_id'] == $bukh3_id) {
                         $bukh3score += ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh3score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh3score -= ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 10 + 300;
                         }
                     }
                 }
             }
             /////////////////////////////////////////////////////////////////////////////////////////
             if ($on['bukh1_id'] == $bukh4_id || $on['bukh2_id'] == $bukh4_id) {
                 $bukh = $bukhs->fetchAll($bukhs->select()->where('id =' . $on['bukh1_id'] . ' OR id = ' . $on['bukh2_id']));
                 foreach ($bukh as $key => $bb) {
                     if ($bb['id'] == $on['bukh1_id']) {
                         $bukh1_tsolid = $bb['tsolid'];
                     } else {
                         $bukh2_tsolid = $bb['tsolid'];
                     }
                 }
                 if ($on['bukh1_id'] == $bukh4_id) {
                     if ($on['davsanbukh_id'] == $bukh4_id) {
                         $bukh4score += ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh4score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh4score -= ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 10 + 300;
                         }
                     }
                 } else {
                     if ($on['davsanbukh_id'] == $bukh4_id) {
                         $bukh4score += ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh4score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh4score -= ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 10 + 300;
                         }
                     }
                 }
             }
             /////////////////////////////////////////////////////////////////////////////////////////
             if ($on['bukh1_id'] == $bukh5_id || $on['bukh2_id'] == $bukh5_id) {
                 $bukh = $bukhs->fetchAll($bukhs->select()->where('id =' . $on['bukh1_id'] . ' OR id = ' . $on['bukh2_id']));
                 foreach ($bukh as $key => $bb) {
                     if ($bb['id'] == $on['bukh1_id']) {
                         $bukh1_tsolid = $bb['tsolid'];
                     } else {
                         $bukh2_tsolid = $bb['tsolid'];
                     }
                 }
                 if ($on['bukh1_id'] == $bukh5_id) {
                     if ($on['davsanbukh_id'] == $bukh5_id) {
                         $bukh5score += ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh5score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh5score -= ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 10 + 300;
                         }
                     }
                 } else {
                     if ($on['davsanbukh_id'] == $bukh5_id) {
                         $bukh5score += ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh5score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh5score -= ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 10 + 300;
                         }
                     }
                 }
             }
             /////////////////////////////////////////////////////////////////////////////////////////
             if ($on['bukh1_id'] == $bukh6_id || $on['bukh2_id'] == $bukh6_id) {
                 $bukh = $bukhs->fetchAll($bukhs->select()->where('id =' . $on['bukh1_id'] . ' OR id = ' . $on['bukh2_id']));
                 foreach ($bukh as $key => $bb) {
                     if ($bb['id'] == $on['bukh1_id']) {
                         $bukh1_tsolid = $bb['tsolid'];
                     } else {
                         $bukh2_tsolid = $bb['tsolid'];
                     }
                 }
                 if ($on['bukh1_id'] == $bukh6_id) {
                     if ($on['davsanbukh_id'] == $bukh6_id) {
                         $bukh6score += ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh6score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh6score -= ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 10 + 300;
                         }
                     }
                 } else {
                     if ($on['davsanbukh_id'] == $bukh6_id) {
                         $bukh6score += ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh6score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh6score -= ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 10 + 300;
                         }
                     }
                 }
             }
             /////////////////////////////////////////////////////////////////////////////////////////
             if ($on['bukh1_id'] == $bukh7_id || $on['bukh2_id'] == $bukh7_id) {
                 $bukh = $bukhs->fetchAll($bukhs->select()->where('id =' . $on['bukh1_id'] . ' OR id = ' . $on['bukh2_id']));
                 foreach ($bukh as $key => $bb) {
                     if ($bb['id'] == $on['bukh1_id']) {
                         $bukh1_tsolid = $bb['tsolid'];
                     } else {
                         $bukh2_tsolid = $bb['tsolid'];
                     }
                 }
                 if ($on['bukh1_id'] == $bukh7_id) {
                     if ($on['davsanbukh_id'] == $bukh7_id) {
                         $bukh7score += ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh7score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh7score -= ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 10 + 300;
                         }
                     }
                 } else {
                     if ($on['davsanbukh_id'] == $bukh7_id) {
                         $bukh7score += ($tsoluud[$on['bukh1_id']] - $tsoluud[$on['bukh2_id']]) * 20 + 1000;
                         if ($on['davaa_num'] > 1) {
                             $bukh7score += $on['davaa_num'] * 100;
                         }
                     } else {
                         if ($on['davaa_num'] > 1) {
                             $bukh7score -= ($tsoluud[$on['bukh2_id']] - $tsoluud[$on['bukh1_id']]) * 10 + 300;
                         }
                     }
                 }
             }
         }
         $score = $bukh1score + $bukh2score + $bukh3score + $bukh4score + $bukh5score + $bukh6score + $bukh7score;
         $kk = 1;
         $davaagals->update(array('score' => $score), 'fantasy_id =' . $fantasy_id . ' and davaa_num =' . $davaa_num . ' and gal_id =' . $galid);
         $ds->update(array('active' => $kk), 'fantasy_id =' . $fantasy_id . ' and davaa_num =' . $davaa_num);
         $oo = $onoo->fetchAll($onoo->select()->where('fantasyid =' . $fantasy_id . ' and galid =' . $galid));
         $total = 0;
         foreach ($oo as $key => $value) {
             $total = $value['total_score'];
         }
         $total += $score;
         $onoo->update(array('total_score' => $total), 'fantasyid =' . $fantasy_id . ' and galid =' . $galid);
     }
     $ret = array();
     echo Zend_Json::encode($ret);
 }
示例#3
0
 public function ajaxbukhresultAction()
 {
     $id = $this->_request->getParam('id');
     $bukh2_mod = $id % 1000000;
     $bukh2_id = $id % 1000000;
     $id = $id - $bukh2_mod;
     $bukh1_id = $id / 1000000;
     $bukhs = new Model_DbTable_Bukh();
     $bukh = $bukhs->fetchAll($bukhs->select());
     $ret = array();
     $bukh1_lname = "";
     $bukh1_fname = "";
     $bukh2_lname = "";
     $bukh2_fname = "";
     foreach ($bukh as $key => $value) {
         if ($value['id'] == $bukh1_id) {
             $bukh1_lname = $value['lname'];
             $bukh1_fname = $value['fname'];
             $bukh1_id = $value['id'];
         }
         if ($value['id'] == $bukh2_id) {
             $bukh2_lname = $value['lname'];
             $bukh2_fname = $value['fname'];
             $bukh2_id = $value['id'];
         }
     }
     $ret[] = array('bukh1_lname' => $bukh1_lname, 'bukh1_fname' => $bukh1_fname, 'bukh2_lname' => $bukh2_lname, 'bukh2_fname' => $bukh2_fname, 'bukh1_id' => $bukh1_id, 'bukh2_id' => $bukh2_id);
     echo Zend_Json::encode($ret);
 }