Beispiel #1
0
 public function addTo(Set $set)
 {
     $setBean = $set->getBean();
     $recordBean = $this->newBean();
     foreach ($this->directives as $directive) {
         $recordBean->{$directive->field->cleanName} = $directive->value;
     }
     $setBean->{'own' . ucfirst($this->cleanName) . 'List'}[] = $recordBean;
     R::storeAll([$recordBean, $setBean]);
     return $this;
 }
Beispiel #2
0
 public static function create($module, $component, $group)
 {
     if (self::isUnique($module, $component, $group->name)) {
         $bean = R::dispense('perm');
         $groupBean = $group->bean();
         $bean->groupName = $group->name;
         $bean->module = $module;
         $bean->component = $component;
         $groupBean->sharedPermList[] = $bean;
         R::storeAll([$bean, $groupBean]);
         return new Perm($module, $component, $group);
     }
     return null;
 }
Beispiel #3
0
 public static function checkOut($number, Publisher $publisher)
 {
     if (R::count('record', ' number = :number AND isnull(`in`) ', ['number' => $number]) > 0) {
         return null;
     }
     $territoryBean = R::findOne('territory', ' number = :number ', ['number' => $number]);
     if ($territoryBean === null) {
         return null;
     }
     $bean = R::dispense('record');
     $bean->number = $number;
     $bean->out = time();
     $bean->in = null;
     $bean->checkOutBy = App::user()->id;
     $record = new Record($number, $bean);
     $territoryBean->sharedRecordList[] = $bean;
     $publisherBean = $publisher->bean();
     $publisherBean->ownRecordList[] = $bean;
     R::storeAll([$bean, $territoryBean, $publisherBean]);
     $publisher->records[] = $record;
     return $record;
 }
 public function __invoke($school_id)
 {
     $school = $this->schoolService->getSchool($school_id);
     try {
         $equipment = $this->inventoryService->getUnitEquipment($school['registry_no']);
     } catch (Exception $e) {
         $this->logger->error(sprintf('Problem retrieving assets from inventory for school %s', $school_id));
         $this->logger->debug('Exception', [$e->getMessage(), $e->getTraceAsString()]);
         return false;
     }
     $labTypes = $this->getLabTypes();
     $assetTypes = $this->getAssetTypes();
     try {
         $locations = $this->getLocations($school_id, $equipment, $labTypes, $assetTypes);
         R::storeAll($locations);
         $this->logger->info(sprintf('Add assets from inventory for school %s', $school_id));
         return $this->labService->getLabsBySchoolId($school_id);
     } catch (Exception $e) {
         $this->logger->error(sprintf('Problem inserting assets for school %s in database', $school_id));
         $this->logger->debug('Exception', [$e->getMessage(), $e->getTraceAsString()]);
         return false;
     }
 }
Beispiel #5
0
 public function addToSet(Set $set)
 {
     $setBean = $set->getBean();
     if (R::count('skemafield', ' name = ? and skemaset_id = ? ', [$this->name, $setBean->getID()]) > 0) {
         if (Set::$strict) {
             throw new \Exception('Already exists on set');
         }
         return $this;
     }
     $fieldBean = $this->newBean();
     $set->fields[$this->cleanName] = $this;
     $this->set = $set;
     $setBean->ownSkemafieldList[] = $fieldBean;
     R::storeAll([$fieldBean, $setBean]);
     return $this;
 }