/** add and clone last record
  * @access public
  * @param string $broadperiod
  * @param array $coinDataFlat
  * @return void
  */
 public function optionsAddClone($broadperiod, array $coinDataFlat)
 {
     $coinDataFlat = $coinDataFlat[0];
     switch ($broadperiod) {
         case 'IRON AGE':
             if (array_key_exists('denomination', $coinDataFlat)) {
                 $geographies = new Geography();
                 $geography_options = $geographies->getIronAgeGeographyMenu($coinDataFlat['denomination']);
                 $this->_view->form->geographyID->addMultiOptions(array(null => 'Choose geographic region', 'Available regions' => $geography_options));
                 $this->_view->form->geographyID->addValidator('InArray', false, array(array_keys($geography_options)));
             }
             break;
         case 'ROMAN':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 if (!is_null($coinDataFlat['ruler_id'])) {
                     $rulers = new Rulers();
                     $identifier = $rulers->fetchRow($rulers->select()->where('id = ?', $coinDataFlat['ruler_id']));
                     if ($identifier) {
                         $nomisma = $identifier->nomismaID;
                         $rrcTypes = new Nomisma();
                         $this->_view->form->ricID->addMultiOptions(array(null => 'Choose RIC type', 'Available RIC types' => $rrcTypes->getRICDropdownsFlat($nomisma)));
                     }
                 }
                 $reverses = new RevTypes();
                 $reverse_options = $reverses->getRevTypesForm($coinDataFlat['ruler_id']);
                 if ($reverse_options) {
                     $this->_view->form->revtypeID->addMultiOptions(array(null => 'Choose reverse type', 'Available reverses' => $reverse_options));
                     $this->_view->form->revtypeID->setRegisterInArrayValidator(false);
                 } else {
                     $this->_view->form->revtypeID->addMultiOptions(array(null => 'No options available'));
                     $this->_view->form->revtypeID->setRegisterInArrayValidator(false);
                 }
             } else {
                 $this->_view->form->revtypeID->addMultiOptions(array(null => 'No options available'));
                 $this->_view->form->revtypeID->setRegisterInArrayValidator(false);
             }
             if (array_key_exists('ruler_id', $coinDataFlat) && $coinDataFlat['ruler_id'] == '242') {
                 $moneyers = new Moneyers();
                 $moneyer_options = $moneyers->getRepublicMoneyers();
                 $this->_view->form->moneyer->addMultiOptions(array(null => 'Choose moneyer', 'Available moneyers' => $moneyer_options));
                 if (array_key_exists('moneyer', $coinDataFlat)) {
                     if (!is_null($coinDataFlat['moneyer'])) {
                         $identifier = $moneyers->fetchRow($moneyers->select()->where('id = ?', $coinDataFlat['moneyer']));
                         if ($identifier) {
                             $nomisma = $identifier->nomismaID;
                             $rrcTypes = new Nomisma();
                             $this->_view->form->rrcID->addMultiOptions(array(null => 'Choose RRC type', 'Available RRC types' => $rrcTypes->getRRCDropdownsFlat($nomisma)));
                         }
                     }
                 }
             } else {
                 $this->_view->form->moneyer->addMultiOptions(array(null => 'No options available'));
             }
             break;
         case 'EARLY MEDIEVAL':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 $types = new MedievalTypes();
                 $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler_id']);
                 $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Early Medieval type', 'Available types' => $type_options));
             }
             break;
         case 'MEDIEVAL':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 $types = new MedievalTypes();
                 $type_options = $types->getMedievalTypeToRulerMenu($coinDataFlat['ruler_id']);
                 $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Medieval type', 'Available types' => $type_options));
             }
             break;
         case 'POST MEDIEVAL':
             if (array_key_exists('ruler_id', $coinDataFlat)) {
                 $types = new MedievalTypes();
                 $type_options = $types->getMedievalTypeToRulerMenu((int) $coinDataFlat['ruler_id']);
                 $this->_view->form->typeID->addMultiOptions(array(null => 'Choose Post Medieval type', 'Available types' => $type_options));
             }
             break;
         default:
             return false;
     }
 }
Example #2
0
 /** A function to get RRC types for moneyers as json
  * @access public
  * @return mixed
  */
 public function rictypesAction()
 {
     if ($this->getParam('term', false)) {
         $rulers = new Rulers();
         $nomismaID = $rulers->fetchRow($rulers->select()->where('id = ?', $this->getParam('term')))->nomismaID;
         $nomisma = new Nomisma();
         $types = $nomisma->getRICDropdowns($nomismaID);
         if ($types) {
             $response = $types;
         } else {
             $response = array(array('id' => null, 'term' => 'No options available'));
         }
     } else {
         $response = array(array('id' => null, 'term' => 'No ruler specified'));
     }
     echo Zend_Json::encode($response);
 }