public static function getVoted1k(Period $period) { $q = Doctrine_Query::create()->select('v.*')->from('Vote v')->where('v.id_period = ?', $period->getId())->andWhere('v.weight > 50')->execute()->getFirst(); if ($q) { return $q->getPrice(); } else { return false; } }
public static function getSoldArticlesQuery(User $user, Period $period, $c_sort = null) { if (!is_null($c_sort)) { $sortby = $c_sort['sortby']; $order = $c_sort['order']; } else { $sortby = 'pub_date'; $order = 'desc'; } $q = Doctrine_Query::create()->select('c.id, sum(t.amount) as sell_sum, count(cp.id) as sell_count')->from('Content c')->leftJoin('c.Category ct')->leftJoin('c.ContentPurchase cp')->leftJoin('cp.Transaction t with t.id_period = ?', $period->getId())->where('c.id_user = ?', $user->getId())->andWhere('c.state = "public"')->groupBy('c.id')->orderBy("{$sortby} {$order}"); return $q; }
/** * cree une nouvelle periode * @param String $per_name * @param int $per_start * @param int $per_end * @return String $csvResult */ public function addPeriod($per_name, $per_start, $per_end) { $rtn = new ComplexData(); $per = new Period(0, $this->Fundation->getId(), $per_name, $per_start, $per_end); $rtn->addLine(array($per->getState(), $per->getId())); return $rtn->csvArrays(); }
public function getSoldStatsForPeriod(Period $period) { $q = Doctrine_Query::create()->select('u.id, sum(t.amount) as sell_sum, count(t.id) as sell_count, count(c.id) as content_count, sum(c.letters_k) as letter_sum')->from('User u')->leftJoin('u.Content c')->leftJoin('c.ContentPurchase cp')->leftJoin('cp.Transaction t with t.id_period = ?', $period->getId())->where('u.id = ?', $this->getId())->groupBy('u.id')->execute(); return $q->getFirst(); }
/** * Ajoute un droit à un user entre 2 dates. * * @param int $id_user * @param int $date_start * @param int $date_end * @param int $point * @param int $fundation * @return int $state */ public function addUserToDroit($id_user, $date_start, $date_end, $point = 0, $fundation = 0) { $Period = new Period(0, 1, '', $date_start, $date_end); $per_id = $Period->getId(); if ($point == 0 && $fundation == 0) { $this->db->query("INSERT INTO tj_usr_rig_jur (usr_id, rig_id, per_id) VALUES ('%u', '%u', '%u')", array($id_user, $this->id, $Period->getId())); } elseif ($point == 0) { $this->db->query("INSERT INTO tj_usr_rig_jur (usr_id, rig_id, per_id, fun_id) VALUES ('%u', '%u', '%u', '%u')", array($id_user, $this->id, $Period->getId(), $fundation)); } elseif ($fundation == 0) { $this->db->query("INSERT INTO tj_usr_rig_jur (usr_id, rig_id, per_id, poi_id) VALUES ('%u', '%u', '%u', '%u')", array($id_user, $this->id, $Period->getId(), $point)); } else { $this->db->query("INSERT INTO tj_usr_rig_jur (usr_id, rig_id, per_id, fun_id, poi_id) VALUES ('%u', '%u', '%u', '%u', '%u')", array($id_user, $this->id, $Period->getId(), $fundation, $point)); } if ($this->db->affectedRows() == 1) { return 1; } else { return 400; } }
/** * Ajoute un groupe à un user entre 2 dates. * * @param int $id_user * @param int $date_start * @param int $date_end * @return int $state */ public function addUserToGroup($id_user, $date_start, $date_end) { $Period = new Period(0, 1, '', $date_start, $date_end); $per_id = $Period->getId(); $this->db->query("INSERT INTO tj_usr_grp_jug (usr_id, grp_id, per_id) VALUES ('%u', '%u', '%u')", array($id_user, $this->id, $Period->getId())); if ($this->db->affectedRows() == 1) { return 1; } else { return 400; } }
public static function countWeights(Period $period) { // общая сумма продаж $tSum = BalanceSystemTable::getInstance()->findOneByIdPeriod($period->getId())->getToPayPUsers(); $q = UserTable::addPUserQuery()->execute(); foreach ($q as $user) { if (($bu = BalanceUserTable::getByUserIdAndPeriodId($user->getId(), $period->getId())) !== false) { $uWeight = $bu->getPayable() * 100 / $tSum; $user->setWeight((double) $uWeight); $user->save(); } } }