예제 #1
0
 public function gaUr($medlem)
 {
     if (Security::authorized(FORETAG, $this) or Security::authorized(USER, Medlem::loadById($medlem))) {
         global $db;
         $sql = "UPDATE " . self::KEY_TABLE . " SET lag_id=null, datum=null, medlem_id=null WHERE medlem_id = " . $medlem . " AND foretag_id = " . $this->getId();
         $db->query($sql);
         //remove days payed by foretag (days removed = days until foretagstavling is over)
         //potential issue : if self::TAVLINGSPERIOD_DAGAR is changed during a TAVLING and a user is removed subscriptiontime might be lost
         $slutdatum = date('Y-m-d', strtotime($this->getStartdatum()) + self::TAVLINGSPERIOD_MEDLEMS_DAGAR * 60 * 60 * 24);
         $daydiff = floor((strtotime($slutdatum) - time()) / (60 * 60 * 24));
         $medlemObj = Medlem::LoadById($medlem);
         if ($daydiff < 0) {
             $daydiff = 0;
         }
         $medlemObj->setPaidUntilByForetag($daydiff * -1);
         $medlemObj->commit();
     }
 }