Пример #1
0
 /**
  * standard SS method
  *
  */
 function updateCMSFields(FieldSet &$fields)
 {
     if ($brands = Dataobject::get("Brand")) {
         $fields->removeFieldFromTab("Root.Content.Main", "Model");
         $fields->addFieldToTab('Root.Content.Main', new DropdownField('BrandID', 'Please choose an brand', $brands->map("ID", "Title", "Please Select")), "FeaturedProduct");
     }
 }
 /**
  * Get the Category name to add into the CategorySections array drop-down list
  *
  * @return array $aCategorySections An array of mapped IDs and values
  */
 public function FormCategorySections()
 {
     // Set an empty return array
     $aCategorySections = array();
     // Get all Categorys
     $oCategorySections = Dataobject::get('FormCategory');
     if ($oCategorySections) {
         // Loop through each Category
         foreach ($oCategorySections as $category) {
             // Add it into the Categorys array
             $aCategorySections[$category->ID] = $category->Title;
         }
         // Return the Categorys array
         return $aCategorySections;
     }
 }
 function getCMSFields()
 {
     $fields = new FieldList();
     $fields->add(new TextField('Name', 'Name'));
     $fields->add(new HtmlEditorField('Description', 'Description'));
     $fields->add(new DropdownField('Status', 'Status', $this->dbObject('Status')->enumValues()));
     $fields->add($ddl_program = new CheckboxsetField('Program', 'Program', InteropProgramType::get()->filter('HasCapabilities', true)->sort('Order')->map("ID", "ShortName")));
     $fields->add($ddl_version = new CheckboxsetField('Version', 'Version', InteropProgramVersion::get()->map("ID", "Name")));
     $fields->add($ddl_type = new DropdownField('TypeID', 'Type', Dataobject::get("InteropCapabilityType")->map("ID", "Name", "Please Select")));
     if ($this->ID > 0) {
         $ddl_program->setValue('ID', $this->Program());
         $ddl_version->setValue('ID', $this->Version());
         $ddl_type->setValue($this->TypeID);
     }
     return $fields;
 }
 /**
  * Provides a GUI for the insert embed content popup
  * @return Form
  **/
 public function EmbedContentForm()
 {
     if (!Permission::check('CMS_ACCESS_CMSMain')) {
         return;
     }
     $contenttype = $this->request->requestVar('EmbedContentType');
     $allContentTypes = array('Container' => 'Empty Block', 'Page' => 'Pages in the Site Tree', 'DataObject' => 'Other Data Object in the site', 'External' => 'External site content');
     $headerField = CompositeField::create(LiteralField::create('Heading', sprintf('<h3 class="htmleditorfield-embedcontentform-heading insert">%s</h3>', "Insert Content")))->addExtraClass('CompositeField composite cms-content-header nolabel');
     $fields = array(DropdownField::create('EmbedContentType', 'Embed Content Type', $allContentTypes, $contenttype)->setHasEmptyDefault(true)->addExtraClass('reloadFormOnSelect'));
     if ($contenttype) {
         if ($contenttype == 'External') {
             $fields[] = TextField::create('ExternalURL', 'External URL', $this->request->requestVar('ExternalURL'));
         } elseif ($contenttype == 'DataObject' || $contenttype == 'Page') {
             $allDataObjectClasses = ClassInfo::subclassesFor($contenttype);
             $dataobjecttype = $this->request->requestVar('EmbedContentDataObjectType');
             $fields[] = DropdownField::create('EmbedContentDataObjectType', 'Data Object Type', $allDataObjectClasses, $dataobjecttype)->setHasEmptyDefault(true)->addExtraClass('reloadFormOnSelect');
             if ($dataobjecttype) {
                 $fields[] = DropdownField::create('EmbedContentDataObjectID', 'Please choose an object', Dataobject::get($dataobjecttype)->map("ID", "Title"), $this->request->requestVar('EmbedContentDataObjectID'))->setHasEmptyDefault(true);
             }
         }
         if ($contenttype != 'Container') {
             $fields[] = DropdownField::create('EmbedTemplate', 'Please choose an View', self::getTemplates($contenttype), $this->request->requestVar('EmbedTemplate'))->setHasEmptyDefault(false);
         }
         if (!self::isInlineTemplate($contenttype, $this->request->requestVar('EmbedTemplate')) || $contenttype == 'Container') {
             $widthField = new FieldGroup(TextField::create('EmbedWidth', 'Value', $this->request->requestVar('EmbedWidth')), DropdownField::create('EmbedWidthUnit', 'Unit', array('px' => 'Pixel', 'em' => 'Font Size', '%' => 'Percent'), $this->request->requestVar('EmbedWidthUnit')));
             $widthField->setTitle("Width");
             $fields[] = $widthField;
             $heightField = new FieldGroup(TextField::create('EmbedHeight', 'Value', $this->request->requestVar('EmbedHeight'))->addExtraClass('clear'), DropdownField::create('EmbedHeightUnit', 'Unit', array('px' => 'Pixel', 'em' => 'Font Size', '%' => 'Percent'), $this->request->requestVar('EmbedHeightUnit')));
             $heightField->setTitle("Height");
             $fields[] = $heightField;
             $fields[] = DropdownField::create('EmbedFloat', 'Align(Float)', array(' ' => 'None', 'left' => 'Left', 'right' => 'Right'), $this->request->requestVar('EmbedFloat'));
         }
         if (self::hasCSSClasses()) {
             $fields[] = DropdownField::create('EmbedCSSClass', 'CSS Class', self::getCSSClasses(), $this->request->requestVar('EmbedCSSClass'));
         }
     }
     // essential fields
     $fields = FieldList::create(array($headerField, CompositeField::create($fields)->addExtraClass('ss-embedcontent-fields')));
     $ActionName = "Insert/Update Content";
     // actions
     $actions = FieldList::create(array(FormAction::create('insert', _t('Embedcontent.BUTTONINSERTSHORTCODE', $ActionName))->addExtraClass('ss-ui-action-constructive')->setAttribute('data-icon', 'accept')->setUseButtonTag(true)));
     // form
     $form = Form::create($this, "EmbedContentForm", $fields, $actions)->loadDataFrom($this)->addExtraClass('htmleditorfield-form htmleditorfield-embedcontent cms-dialog-content');
     return $form;
 }
 public function getHTMLFragments($gridField)
 {
     Requirements::css(FindManyManyDropdown_PATH . '/css/FindManyManyDropdown.css');
     Requirements::javascript(FindManyManyDropdown_PATH . '/javascript/FindManyManyDropdownForm.js');
     $targetFragment = 'before';
     if ($gridField->getConfig()->getComponentByType('GridFieldButtonRow')) {
         $targetFragment = 'buttons-before-right';
     }
     $dataClass = $gridField->list->dataClass;
     $dropdownOptions = new DropdownField('gridfield_relationdropdown', 'Please choose an object', Dataobject::get($dataClass)->map("ID", "Title"));
     $dropdownOptions->setEmptyString('Select:');
     $addAction = new GridField_FormAction($gridField, 'gridfield_relationadd', _t('GridField.LinkExisting', "Link Existing"), 'addDDto', 'addDDto');
     $addAction->setAttribute('data-icon', 'chain--plus');
     $forTemplate = new ArrayData(array());
     $forTemplate->Fields = new ArrayList();
     $forTemplate->Fields->push($dropdownOptions);
     $forTemplate->Fields->push($addAction);
     return array($targetFragment => $forTemplate->renderWith('FindManyManyDropdownForm'));
 }
Пример #6
0
 function RecentEvents()
 {
     $now = date('Y-m-d H:i:s');
     if ($allpastEvents = Dataobject::get('CleanUpGroup', "(FromDate < '{$now}')", "FromDate ASC", '', 30)) {
         return $allpastEvents;
     } else {
         return false;
     }
 }
Пример #7
0
 function _valida($do)
 {
     $this->rapyd->load('dataobject');
     $obr = $do->get('obr');
     $obra = new Dataobject('obra');
     $obra->load($obr);
     $rr = $this->ivaplica2();
     $ivaa = $do->get('ivaa');
     $ivag = $do->get('ivag');
     $ivar = $do->get('ivar');
     $exento = $do->get('exento');
     $subtotal = $do->get('subtotal');
     $cod_prov = $do->get('cod_prov');
     $otrasrete = $do->get('otrasrete');
     $ivag = $ivag != 0 ? $subtotal * $rr['tasa'] / 100 : 0;
     $ivar = $ivar != 0 ? $subtotal * $rr['redutasa'] / 100 : 0;
     $ivaa = $ivaa != 0 ? $subtotal * $rr['sobretasa'] / 100 : 0;
     $do->set('ivaa', $ivaa);
     $do->set('ivag', $ivag);
     $do->set('ivar', $ivar);
     $iva = $ivag + $ivar + $ivaa;
     //$cod_prov     = $obra->get('cod_prov'  );
     $porcent = $obra->get('porcent');
     $tipo = $obra->get('tipo');
     $do->set('estadmin', $obra->get('codigoadm'));
     $do->set('fondo', $obra->get('fondo'));
     $creten = $do->get('creten');
     $reteiva_prov = $this->datasis->dameval("SELECT reteiva FROM sprv WHERE proveed = '{$cod_prov}'");
     if ($tipo == 'Compra') {
         $do->set('creten', '');
         $do->set('reten', 0);
     }
     $rete = $this->datasis->damerow("SELECT base1,tari1,pama1 FROM rete WHERE codigo='{$creten}'");
     if ($reteiva_prov != 75) {
         $reteiva_prov = 100;
     }
     $error = '';
     $reteiva = $mivag = $mivar = $mivaa = 0;
     $reten = 0;
     if (!empty($cod_prov)) {
         $reteiva = $iva * $reteiva_prov / 100;
         if ($rete) {
             if (substr($creten, 0, 1) == '1') {
                 $reten = round($subtotal * $rete['base1'] * $rete['tari1'] / 10000, 2);
             } else {
                 $reten = round(($subtotal - $rete['pama1']) * $rete['base1'] * $rete['tari1'] / 10000, 2);
             }
             if ($reten < 0) {
                 $reten = 0;
             }
             $do->set('reten', $reten);
         }
     } else {
         $reteiva = 0;
     }
     $impt = $impm = 0;
     $pimpm = $this->datasis->traevalor('IMPMUNICIPAL');
     $pimpt = $this->datasis->traevalor('IMPTIMBRE');
     $pcrs = $this->datasis->traevalor('CRS');
     if ($do->get('imptimbre') != 0) {
         $impt = $subtotal * $pimpt / 100;
     }
     if ($do->get('impmunicipal') != 0) {
         $impm = $subtotal * $pimpm / 100;
     }
     $crs = 0;
     if ($do->get('crs') != 0) {
         $crs = $obra->get('monto') * $pcrs / 100;
     }
     $total2 = $iva + $subtotal;
     $amortiza = $do->get('amortiza');
     //if($do->get('amortiza')!=0)
     //	$amortiza = $total2 * $porcent / 100;
     $total = $total2 - $reteiva - $reten - $amortiza - $otrasrete - $impt - $impm - $crs;
     //echo "</br>".$total2;
     //echo "</br>".$amortiza;
     //echo "</br>".$reten;
     //echo "</br>".$reteiva;
     //echo "</br>".$impt;
     //echo "</br>".$impm;
     //echo "</br>".$crs;
     //echo "</br>".$total;
     //exit();
     $do->set('impmunicipal', $impm);
     $do->set('imptimbre', $impt);
     $do->set('crs', $crs);
     $do->set('pimpmunicipal', $pimpm);
     $do->set('pimptimbre', $pimpt);
     $do->set('pcrs', $pcrs);
     $do->set('iva', $iva);
     $do->set('tivag', $rr['tasa']);
     $do->set('tivar', $rr['redutasa']);
     $do->set('tivaa', $rr['sobretasa']);
     $do->set('mivag', $ivag > 0 ? $ivag * 100 / $rr['tasa'] : 0);
     $do->set('mivar', $ivar > 0 ? $ivar * 100 / $rr['redutasa'] : 0);
     $do->set('mivaa', $ivaa > 0 ? $ivaa * 100 / $rr['sobretasa'] : 0);
     //$do->set('subtotal'      , $subtotal            );
     $do->set('exento', $exento);
     $do->set('reteiva', $reteiva);
     $do->set('total', $total);
     $do->set('total2', $total2);
     $do->set('status', 'O1');
     $do->set('cod_prov', $cod_prov);
     $do->set('breten', $rete['tari1']);
     $do->set('amortiza', $amortiza);
     $do->set('porcent', $porcent);
     $do->set('multiple', 'N');
     if (empty($error)) {
         if (empty($do->loaded)) {
             $nodirect = $this->datasis->fprox_numero('nodirect');
             $do->set('numero', $nodirect);
             $do->pk = array('numero' => $nodirect);
         }
     }
     if (!empty($error)) {
         $do->error_message_ar['pre_ins'] = $error;
         $do->error_message_ar['pre_upd'] = $error;
         return false;
     }
 }
 function Events()
 {
     $now = date('Y-m-d H:i:s');
     $oAllEvents = Dataobject::get('CleanUpGroup', "(ToDate > '{$now}')", 'FromDate ASC', '', 10);
     if ($oAllEvents) {
         return $oAllEvents;
     } else {
         return array('Events' => null, 'Message' => 'Sorry no events for us to show you');
     }
 }