Inheritance: extends yupe\components\WebModule
Exemple #1
0
<?php

$this->breadcrumbs = array(CartModule::t($model->parentName() . ' Fields', $model->parentName()) => array('admin'), $model->varname => array('view', 'id' => $model->id), CartModule::t('Update'));
$this->menu = array(array('label' => CartModule::t('Create'), 'url' => array('create')), array('label' => CartModule::t('View'), 'url' => array('view', 'id' => $model->id)), array('label' => CartModule::t('Manage ' . $model->parentName() . ' Field', $model->parentName()), 'url' => array('admin')));
?>

<h1><?php 
echo CartModule::t('Update "{varname}"', '', array('{varname}' => $model->varname));
?>
</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model));
Exemple #2
0
function getTreeCheckbox($model, $catalogs, $setCatalogs = array(), $ulId = 'tree')
{
    $setCat = array();
    foreach ($setCatalogs as $catalog) {
        $setCat[$catalog->id] = $catalog;
    }
    $basePath = Yii::getPathOfAlias('application.modules.cart.views.asset');
    $baseUrl = Yii::app()->getAssetManager()->publish($basePath);
    $cs = Yii::app()->getClientScript();
    $cs->registerCoreScript('jquery');
    $css = '
			/* Catalog Tree */
			#tree {
	    		list-style: none;
				padding-left:1em;
	    	}
			#tree ul {
	    		list-style: none;
				padding-left: 2em;
	    	}
			#tree input {
				margin-right: .5em;
			}
			div.form li label {
				display:inline;
			}
		';
    $js = '
			$(document).ready(function(){
				$("#tree input").click(function(){
					if (this.checked) {
						$(this).parent("li").find("input").attr("checked", "checked");
					}
    			});
				$("#check_all").click(function(){
					$("#tree input").attr("checked", "checked");
					return false;
				});
				$("#uncheck_all").click(function(){
					$("#tree input").removeAttr("checked");
					return false;
				});
    			
			});
		';
    $cs->registerCss(__CLASS__ . '#form', $css);
    $cs->registerScript(__CLASS__ . '#form', $js);
    $content = "<div class=\"row catalogs\"><p><a href=\"#\" id=\"check_all\">" . CartModule::t('Check All') . "</a> | <a href=\"#\" id=\"uncheck_all\">" . CartModule::t('Uncheck All') . "</a></p><ul id=\"{$ulId}\">";
    foreach ($catalogs as $item) {
        $htmlOptions = array();
        $htmlOptions['value'] = $item['self']->id;
        if ($model->isNewRecord) {
            if (isset($setCat[$item['self']->id]) && $setCat[$item['self']->id]) {
                $htmlOptions['checked'] = 'checked';
            }
        } else {
            if (isset($setCat[$item['self']->id]->id)) {
                $htmlOptions['checked'] = 'checked';
            }
        }
        $content .= '<li>' . CHtml::activeCheckBox($model, "catalogs[" . $item['self']->id . "]", $htmlOptions) . '' . CHtml::activeLabelEx($model, "catalogs[" . $item['self']->id . "]", array('label' => $item['self']->name)) . getTreeCheckboxChilds($model, $item['childs'], $setCat) . ' </li>';
    }
    $content .= '</ul></div>';
    return $content;
}
Exemple #3
0
<?php

$this->breadcrumbs = array(CartModule::t('Products', 'product') => array('admin'), $model->name => array('view', 'id' => $model->id), CartModule::t('Update'));
$this->menu = array(array('label' => CartModule::t('Manage Products', 'product'), 'url' => array('admin')), array('label' => CartModule::t('Create Product', 'product'), 'url' => array('create')), array('label' => CartModule::t('View Product', 'product'), 'url' => array('view', 'id' => $model->id)));
?>

<h1><?php 
echo CartModule::t('Update Product', 'product') . ' #' . $model->id;
?>
</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model, 'ProductValue' => $ProductValue, 'newPhoto' => $newPhoto, 'newRelation' => $newRelation, 'catalogs' => $catalogs, 'cat_list' => $cat_list));
Exemple #4
0
<?php

$this->breadcrumbs = array(CartModule::t($model->parentName() . ' Fields', $model->parentName()) => array('admin'), CartModule::t('Create'));
$this->menu = array(array('label' => CartModule::t('Manage ' . $model->parentName() . ' Field', $model->parentName()), 'url' => array('admin')));
?>

<h1><?php 
echo CartModule::t('Create ' . $model->parentName() . ' Field', $model->parentName());
?>
</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model));
 public static function itemAlias($type, $code = NULL)
 {
     $_items = array('field_type' => array('INTEGER' => CartModule::t('INTEGER'), 'VARCHAR' => CartModule::t('VARCHAR'), 'TEXT' => CartModule::t('TEXT'), 'DATE' => CartModule::t('DATE'), 'FLOAT' => CartModule::t('FLOAT'), 'BOOL' => CartModule::t('BOOL'), 'BLOB' => CartModule::t('BLOB'), 'BINARY' => CartModule::t('BINARY')), 'required' => array(self::REQUIRED_NO => CartModule::t('No'), self::REQUIRED_YES => CartModule::t('Yes')), 'visible' => array(self::VISIBLE_ALL => CartModule::t('For all'), self::VISIBLE_REGISTER_USER => CartModule::t('Registered users'), self::VISIBLE_ONLY_OWNER => CartModule::t('Only owner'), self::VISIBLE_NO => CartModule::t('Hidden')));
     if (isset($code)) {
         return isset($_items[$type][$code]) ? $_items[$type][$code] : false;
     } else {
         return isset($_items[$type]) ? $_items[$type] : false;
     }
 }
Exemple #6
0
function getTreeSelect($selfId = 0)
{
    $tree = array(0 => CartModule::t('No'));
    $items = Catalog::getTree();
    //echo '<pre>'; print_r($items); die();
    $prefix = '';
    foreach ($items as $item) {
        if ($item['self']->id != $selfId) {
            $tree[$item['self']->id] = $item['self']->name;
            $tree = getChilds($tree, $item['childs'], $selfId);
        }
    }
    return $tree;
}
Exemple #7
0
	<?php 
        echo $form->errorSummary($model);
        ?>
	
	<div class="row">
		<?php 
        echo $form->labelEx($model, 'importFile');
        ?>
		<?php 
        echo $form->fileField($model, 'importFile', array('size' => 60, 'maxlength' => 255));
        ?>
		<?php 
        echo $form->error($model, 'importFile');
        ?>
	</div>
	
	<div class="row buttons">
		<?php 
        echo CHtml::submitButton(CartModule::t('Import', 'import'));
        ?>
	</div>

<?php 
        $this->endWidget();
        ?>

</div><!-- form -->
<?php 
    }
}
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     $array = parent::attributeLabels();
     $array['catalogs'] = CartModule::t('Catalogs');
     return $array;
 }
Exemple #9
0
 public function itemAlias($type, $code = NULL)
 {
     $_items = array('Status' => array(self::STATUS_NOACTIVE => CartModule::t('Not active'), self::STATUS_ACTIVE => CartModule::t('Active'), self::STATUS_COLLECTION => CartModule::t('Collection')));
     if (isset($code)) {
         return isset($_items[$type][$code]) ? $_items[$type][$code] : false;
     } else {
         return isset($_items[$type]) ? $_items[$type] : false;
     }
 }
Exemple #10
0
                }
            }
            $field = array('label' => Yii::t("cart", $field->title), 'name' => $field->varname, 'value' => $stt);
            if (is_array($field['value'])) {
                $field['value'] = $field['value'][''];
            }
            array_push($attributes, $field);
        } else {
            $field = array('label' => Yii::t("cart", $field->title), 'name' => $field->varname, 'value' => $field->range ? $model->value->range($field->range, $model->value->getAttribute($field->varname)) : $model->value->getAttribute($field->varname));
            if (is_array($field['value'])) {
                $field['value'] = $field['value'][''];
            }
            array_push($attributes, $field);
        }
    }
}
array_push($attributes, 'url', 'tags', array('name' => 'type', 'value' => $model->itemAlias("Type", $model->type)), array('name' => 'status', 'value' => $model->itemAlias("Status", $model->status)));
$relation = '';
foreach ($model->relation as $n => $m) {
    $relation .= '<div style="float:left;text-align:center;margin:3px;padding:5px;background:#fff;">' . '<div class="photo">' . ($m->photo ? CHtml::link($m->photo->img(array("w" => "100")), array('view', 'id' => $m->id)) : '') . '</div>' . '<div class="title" style="bottom:55px; text-align:left">' . CHtml::link(CHtml::encode($m->name), array('view', 'id' => $m->id)) . '</div>' . '<div class="pay" style="bottom:30px;">' . str_replace(' ', '<i style="padding:0 .1em;"></i>', number_format($m->price, 0, ',', ' ')) . '</div>' . '</div>';
}
array_push($attributes, array('name' => 'relation', 'type' => 'raw', 'label' => CartModule::t('Relation Products', 'product'), 'value' => $relation));
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => $attributes));
function catList($model)
{
    $catalogs = array();
    foreach ($model->catalogs as $catalog) {
        array_push($catalogs, CHtml::link($catalog->name, array('catalog/view', 'id' => $catalog->id)));
    }
    return $catalogs;
}
Exemple #11
0
 public function init()
 {
     Yii::import('mod.cart.CartModule');
     CartModule::registerAssets();
 }
Exemple #12
0
<?php

$this->breadcrumbs = array(CartModule::t('Catalogs', 'catalog') => array('admin'), CartModule::t('Create'));
$this->menu = array(array('label' => CartModule::t('Manage Catalog', 'catalog'), 'url' => array('admin')));
?>

<h1><?php 
echo CartModule::t('Create Catalog', 'catalog');
?>
</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model));
 public function attributeLabels()
 {
     $labels = array($this->ownerField => CartModule::t('Owner ID', $this->parentName()));
     $model = $this->_getModel();
     foreach ($model as $field) {
         $labels[$field->varname] = CartModule::t($field->title, $this->parentName());
     }
     return $labels;
 }
Exemple #14
0
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     return array('importFile' => CartModule::t('Import from file', 'import'));
 }
 function productImport($array)
 {
     if ($array['id'] || $array['artno']) {
         $log = array('error' => 0, 'warning' => '', 'note' => '');
         if ($array['id']) {
             $product = $this->loadModel($array['id']);
         } else {
             $product = Product::model()->findByAttributes(array('artno' => $array['artno']));
         }
         if ($product) {
             $value = $product->value;
             $log['new'] = 0;
         } else {
             $log['new'] = 1;
             $product = new Product();
             $value = new ProductValue();
         }
         foreach ($array as $f => $v) {
             if (array_key_exists($f, $product->attributes)) {
                 if (in_array($f, array('id', 'photo_id', 'price', 'store', 'type', 'status'))) {
                     if ($f != 'photo_id' && $f != 'id') {
                         $product->setAttribute($f, (int) $v);
                     }
                 } else {
                     $product->setAttribute($f, $v);
                 }
             } elseif (array_key_exists($f, $value->attributes)) {
                 $value->setAttribute($f, $v);
             }
         }
         if ($product->validate() && $value->validate()) {
             if ($log['new']) {
                 $product->save();
                 $value->pr_id = $product->id;
             }
             if (isset($array['catalogs'])) {
                 $catalogs = explode('|', $array['catalogs']);
                 foreach ($catalogs as $branch) {
                     $parent_id = 0;
                     foreach (explode('=>', $branch) as $cat_name) {
                         $catalog = Catalog::model()->findByAttributes(array('name' => $cat_name, 'pid' => $parent_id));
                         if ($catalog) {
                             $carRel = new CatalogRelation();
                             $carRel->cid = $parent_id = $catalog->id;
                             $carRel->pr_id = $product->id;
                             $carRel->save();
                         } else {
                             $log['note'] = CartModule::t('Not found catalog "{catalog}" in branch "{branch}".', 'import', array('{branch}' => $branch, '{catalog}' => $cat_name));
                         }
                     }
                 }
             }
             if ($array['photo']) {
                 $photos = explode('|', $array['photo']);
                 foreach ($photos as $photo) {
                     $path = Yii::app()->getModule('cart')->importPathPhotos . '/' . $photo;
                     $newPhoto = new Photo();
                     if ($newPhoto->addByFile($path, $product->id)) {
                         if (!$product->photo_id && $newPhoto->id) {
                             $product->photo_id = $newPhoto->id;
                             $product->save();
                         }
                     } else {
                         $log['warning'] = CartModule::t('Failed to add photo: {photo}', 'import', array('{photo}' => $photo));
                     }
                 }
             }
             $value->save();
             $product->save();
             if ($log['new']) {
                 $log['message'] = CartModule::t('Addded product name (artno)', 'import', $array);
             } else {
                 $log['message'] = CartModule::t('Changed product name (artno)', 'import', $array);
             }
         } else {
             $log['error'] = 1;
             if (!$product->validate()) {
                 $log['message'] = CartModule::t('Product validation error', 'import') . ' (' . CHtml::errorSummary($product) . ')<br/>';
             }
             if (!$value->validate()) {
                 $log['message'] = CartModule::t('Product fields validation error', 'import') . ' (' . CHtml::errorSummary($value) . ')';
             }
         }
         return $log;
     } else {
         return array('message' => CartModule::t('Not found the ID and Product Marking', 'import'));
     }
 }
Exemple #16
0
<?php

$this->breadcrumbs = array(CartModule::t('Catalogs', 'catalog') => array('admin'), CartModule::t('Manage'));
$this->menu = array(array('label' => CartModule::t('Create Catalog', 'catalog'), 'url' => array('create')));
Yii::app()->clientScript->registerScript('search', "\n\$('.search-button').click(function(){\n\t\$('.search-form').toggle();\n\treturn false;\n});\n\$('.search-form form').submit(function(){\n\t\$.fn.yiiGridView.update('catalog-grid', {\n\t\tdata: \$(this).serialize()\n\t});\n\treturn false;\n});\n");
?>

<h1><?php 
echo CartModule::t('Manage Catalogs', 'catalog');
?>
</h1>

<p><?php 
echo CartModule::t('You may optionally enter a comparison operator (<b>&lt;</b>, <b>&lt;=</b>, <b>&gt;</b>, <b>&gt;=</b>, <b>&lt;&gt;</b> or <b>=</b>) at the beginning of each of your search values to specify how the comparison should be done.');
?>
</p>

<?php 
echo CHtml::link(CartModule::t('Advanced Search'), '#', array('class' => 'search-button'));
?>
<div class="search-form" style="display:none">
<?php 
$this->renderPartial('_search', array('model' => $model));
?>
</div><!-- search-form -->

<?php 
$this->widget('zii.widgets.grid.CGridView', array('id' => 'catalog-grid', 'dataProvider' => $model->search(), 'filter' => $model, 'columns' => array('id', 'pid', 'url', 'name', 'description', 'position', array('name' => 'status', 'value' => '$data->itemAlias("Status",$data->status)', 'filter' => $model->itemAlias("Status")), array('class' => 'CButtonColumn'))));
Exemple #17
0
 /**
  * @return array customized attribute labels (name=>label)
  */
 public function attributeLabels()
 {
     return array('id' => CartModule::t('ID', 'photo'), 'prefix' => CartModule::t('Prefix', 'photo'), 'ngroup' => CartModule::t('Ngroup', 'photo'), 'filename' => CartModule::t('Filename', 'photo'), 'createdate' => CartModule::t('Createdate', 'photo'), 'title' => CartModule::t('Title', 'photo'), 'description' => CartModule::t('Description', 'photo'), 'status' => CartModule::t('Status', 'photo'));
 }
Exemple #18
0
<?php

$this->breadcrumbs = array(CartModule::t('Catalogs', 'catalog') => array('admin'), $model->name => array('view', 'id' => $model->id), CartModule::t('Update'));
$this->menu = array(array('label' => CartModule::t('Manage Catalog', 'catalog'), 'url' => array('admin')), array('label' => CartModule::t('Create Catalog', 'catalog'), 'url' => array('create')), array('label' => CartModule::t('View Catalog', 'catalog'), 'url' => array('view', 'id' => $model->id)));
?>

<h1><?php 
echo CartModule::t('Update Catalog', 'catalog') . ' &laquo;' . $model->name . '&raquo;';
?>
</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model));
Exemple #19
0
<?php

$this->breadcrumbs = array(CartModule::t('Products', 'product') => array('admin'), CartModule::t('Create'));
$this->menu = array(array('label' => CartModule::t('Manage Products', 'product'), 'url' => array('admin')));
?>

<h1><?php 
echo CartModule::t('Create Product', 'product');
?>
</h1>

<?php 
echo $this->renderPartial('_form', array('model' => $model, 'ProductValue' => $ProductValue, 'newPhoto' => $newPhoto, 'newRelation' => $newRelation, 'catalogs' => $catalogs, 'cat_list' => $cat_list));
Exemple #20
0
    ?>
</div>
			<div><?php 
    echo CHtml::linkButton(CartModule::t('Delete Relation', 'product'), array('submit' => array('delrel', 'pid' => $model->id, 'pr_id' => $m->id), 'confirm' => CartModule::t('Are you sure to delete this relation?', 'product')));
    ?>
</div>
		</div>
	<?php 
}
?>
	


	<div class="row buttons">
		<?php 
echo CHtml::submitButton($model->isNewRecord ? CartModule::t('Create') : CartModule::t('Save'));
?>
	</div>

<?php 
$this->endWidget();
?>

</div><!-- form --><?php 
function getTreeCheckbox($model, $catalogs, $setCat = array(), $ulId = 'tree')
{
    $cats = Catalog::model()->with('fields')->findAll();
    $js_cats_list = array();
    foreach ($cats as $cat) {
        $fields = array();
        foreach ($cat->fields as $field) {
Exemple #21
0
 public function itemAlias($type, $code = NULL)
 {
     $_items = array('Status' => array(self::STATUS_NOACTIVE => CartModule::t('Hidden'), self::STATUS_ACTIVE => CartModule::t('Published'), self::STATUS_DELETED => CartModule::t('Deleted')), 'Type' => array('0' => CartModule::t('Product'), '1' => CartModule::t('Kit')));
     if (isset($code)) {
         return isset($_items[$type][$code]) ? $_items[$type][$code] : false;
     } else {
         return isset($_items[$type]) ? $_items[$type] : false;
     }
 }
Exemple #22
0
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'type');
?>
		<?php 
echo $form->textField($model, 'type');
?>
	</div>

	<div class="row">
		<?php 
echo $form->label($model, 'status');
?>
		<?php 
echo $form->dropDownList($model, 'status', $model->itemAlias('Status'));
?>
	</div>

	<div class="row buttons">
		<?php 
echo CHtml::submitButton(CartModule::t('Search'));
?>
	</div>

<?php 
$this->endWidget();
?>

</div><!-- search-form -->
Exemple #23
0
<?php

$this->breadcrumbs = array(CartModule::t('Catalogs', 'catalog') => array('admin'), $model->name);
$this->menu = array(array('label' => CartModule::t('Manage Catalog', 'catalog'), 'url' => array('admin')), array('label' => CartModule::t('Create Catalog', 'catalog'), 'url' => array('create')), array('label' => CartModule::t('Update Catalog', 'catalog'), 'url' => array('update', 'id' => $model->id)), array('label' => CartModule::t('Delete Catalog', 'catalog'), 'url' => '#', 'linkOptions' => array('submit' => array('delete', 'id' => $model->id), 'confirm' => CartModule::t('Are you sure you want to delete this catalog?', 'catalog'))));
?>

<h1><?php 
echo $model->name;
?>
</h1>

<?php 
$fields = array();
foreach ($model->fields as $field) {
    array_push($fields, CHtml::link($field->title, array('productField/view', 'id' => $field->id)));
}
$this->widget('zii.widgets.CDetailView', array('data' => $model, 'attributes' => array('id', array('name' => 'pid', 'type' => 'raw', 'value' => $model->parent ? CHtml::link($model->parent->name, array('view', 'id' => $model->parent->id)) : CartModule::t('No')), 'url', 'name', 'description', array('name' => 'fields', 'type' => 'raw', 'value' => implode(', ', $fields)), 'position', array('name' => 'status', 'value' => $model->itemAlias("Status", $model->status)))));