This commit is contained in:
franck
2013-09-11 15:06:56 +02:00
4 changed files with 542 additions and 20 deletions

View File

@@ -23,6 +23,7 @@
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
/**
* Class AddressCreateForm
@@ -59,65 +60,104 @@ class AddressCreateForm extends BaseForm
"constraints" => array(
new NotBlank()
),
"label" => "address name",
"label" => Translator::getInstance()->trans("Address label *"),
"label_attr" => array(
"for" => "label_create"
),
"required" => true
))
->add("title", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "title"
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title_create"
)
))
->add("firstname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "first name"
"label" => Translator::getInstance()->trans("Firstname"),
"label_attr" => array(
"for" => "firstname_create"
)
))
->add("lastname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "last name"
"label" => Translator::getInstance()->trans("Lastname"),
"label_attr" => array(
"for" => "lastname_create"
)
))
->add("address1", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "address"
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1_create"
)
))
->add("address2", "text", array(
"label" => "address (line 2)"
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address2_create"
)
))
->add("address3", "text", array(
"label" => "address (line 3)"
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address3_create"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "zipcode"
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode_create"
)
))
->add("city", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "city"
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city_create"
)
))
->add("country", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => "country"
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country_create"
)
))
->add("phone", "text", array(
"label" => "phone"
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone_create"
)
))
->add("cellphone", "text", array(
"label" => "cellphone"
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone_create"
)
))
->add("company", "text", array(
"label" => "company"
"label" => Translator::getInstance()->trans("Compagny"),
"label_attr" => array(
"for" => "company_create"
)
))
;
}

View File

@@ -23,6 +23,7 @@
namespace Thelia\Form;
use Symfony\Component\Validator\Constraints\NotBlank;
use Thelia\Core\Translation\Translator;
/**
* Class AddressUpdateForm
@@ -55,6 +56,112 @@ class AddressUpdateForm extends AddressCreateForm
{
parent::buildForm();
$this->formBuilder
->add("label", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Address label *"),
"label_attr" => array(
"for" => "label_update"
),
"required" => true
))
->add("title", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Title"),
"label_attr" => array(
"for" => "title_update"
)
))
->add("firstname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Firstname"),
"label_attr" => array(
"for" => "firstname_update"
)
))
->add("lastname", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Lastname"),
"label_attr" => array(
"for" => "lastname_update"
)
))
->add("address1", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Street Address"),
"label_attr" => array(
"for" => "address1_update"
)
))
->add("address2", "text", array(
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address2_update"
)
))
->add("address3", "text", array(
"label" => Translator::getInstance()->trans("Additional address"),
"label_attr" => array(
"for" => "address3_update"
)
))
->add("zipcode", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Zip code"),
"label_attr" => array(
"for" => "zipcode_update"
)
))
->add("city", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("City"),
"label_attr" => array(
"for" => "city_update"
)
))
->add("country", "text", array(
"constraints" => array(
new NotBlank()
),
"label" => Translator::getInstance()->trans("Country"),
"label_attr" => array(
"for" => "country_update"
)
))
->add("phone", "text", array(
"label" => Translator::getInstance()->trans("Phone"),
"label_attr" => array(
"for" => "phone_update"
)
))
->add("cellphone", "text", array(
"label" => Translator::getInstance()->trans("Cellphone"),
"label_attr" => array(
"for" => "cellphone_update"
)
))
->add("company", "text", array(
"label" => Translator::getInstance()->trans("Compagny"),
"label_attr" => array(
"for" => "company_update"
)
))
;
}
/**

View File

@@ -69,6 +69,11 @@
}
// -- Bootstrap tooltip --
if($('[rel="tooltip"]').length){
$('[rel="tooltip"]').tooltip();
}
// -- Confirm Box --
if($('[data-toggle="confirm"]').length){
$('[data-toggle="confirm"]').click(function(e){

View File

@@ -45,6 +45,7 @@
{if $form_error}<div class="alert alert-danger">{$form_error_message}</div>{/if}
<div class="col-md-6">
<p class="title title-without-tabs">{intl l="Customer informations"}</p>
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
@@ -72,10 +73,9 @@
</div>
{/form_field}
</div>
{loop name="address" type="address" customer="$customer_id" backend_context="1" default="true"}
<div class="col-md-6">
{loop name="address" type="address" customer="$customer_id" backend_context="1"}
<p class="title title-without-tabs">{intl l="Default address"}</p>
{form_field form=$form field='address1'}
<div class="form-group {if $error}has-error{/if}">
@@ -122,6 +122,110 @@
{/form_field}
{/loop}
</div>
<div class="col-md-6">
<p class="title title-without-tabs clearfix">
{intl l="Other addresses"}
<span class="pull-right">
<a class="btn btn-default btn-primary" title="{intl l='Add a new address'}" href="#address_creation_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-plus-sign"></span>
</a>
</span>
</p>
<table class="table table-bordered table-striped">
<thead>
<tr>
<th>{intl l="Address"}</th>
<th>{intl l="Actions"}</th>
</tr>
</thead>
<tbody>
<tr>
<td>
<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
</address>
</td>
<td>
<div class="btn-group">
<a class="btn btn-default btn-xs" title="{intl l='Edit this address'}" href="#edit_address_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl l='Use this address by default'}" href="#use_address_dialog" data-toggle="modal" rel="tooltip">
<span class="glyphicon glyphicon-pushpin"></span>
</a>
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_address_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
<tr>
<td>
<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
</address>
</td>
<td>
<div class="btn-group">
<a class="btn btn-default btn-xs" title="{intl l='Edit this address'}" href="#edit_address_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl l='Use this address by default'}" href="#use_address_dialog" data-toggle="modal" rel="tooltip">
<span class="glyphicon glyphicon-pushpin"></span>
</a>
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_address_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
<tr>
<td>
<address>
<strong>Twitter, Inc.</strong><br>
795 Folsom Ave, Suite 600<br>
San Francisco, CA 94107<br>
<abbr title="Phone">P:</abbr> (123) 456-7890
</address>
</td>
<td>
<div class="btn-group">
<a class="btn btn-default btn-xs" title="{intl l='Edit this address'}" href="#edit_address_dialog" data-toggle="modal">
<span class="glyphicon glyphicon-edit"></span>
</a>
<a class="btn btn-default btn-xs" title="{intl l='Use this address by default'}" href="#use_address_dialog" data-toggle="modal" rel="tooltip">
<span class="glyphicon glyphicon-pushpin"></span>
</a>
<a class="btn btn-default btn-xs customer-delete" title="{intl l='Delete this customer and all his orders'}" href="#delete_address_dialog" data-id="{$ID}" data-toggle="modal">
<span class="glyphicon glyphicon-trash"></span>
</a>
</div>
</td>
</tr>
</tbody>
</table>
</div>
</form>
@@ -149,4 +253,270 @@
</div>
</div>
{* Add an Address *}
{form name="thelia.address.create"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "address_creation_dialog"}
{form_hidden_fields form=$form}
{form_field form=$form field='label'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Label'}">
</div>
{/form_field}
{form_field form=$form field='company'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Company'}">
</div>
{/form_field}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
{loop type="title" name="title1"}
<option value="{$ID}">{$LONG}</option>
{/loop}
</select>
</div>
{/form_field}
{form_field form=$form field='firstname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Firstname'}">
</div>
{/form_field}
{form_field form=$form field='lastname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Lastname'}">
</div>
{/form_field}
{form_field form=$form field='address1'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Address'}">
</div>
<div class="form-group">
{form_field form=$form field='address2'}
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
<div class="form-group">
{form_field form=$form field='address3'}
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
{/form_field}
{form_field form=$form field='zipcode'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Zip code'}">
</div>
{/form_field}
{form_field form=$form field='city'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='City'}">
</div>
{/form_field}
{form_field form=$form field='country'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
{loop type="country" name="country1"}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
</div>
{/form_field}
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "address_creation_dialog"
dialog_title = {intl l="Create an address"}
dialog_body = {$smarty.capture.address_creation_dialog nofilter}
dialog_ok_label = {intl l="Create this address"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path='/admin/address/create'}
form_enctype = {form_enctype form=$form}
form_error_message = $form_error_message
}
{/form}
{* Update an Address *}
{form name="thelia.address.update"}
{* Capture the dialog body, to pass it to the generic dialog *}
{capture "edit_address_dialog"}
{form_hidden_fields form=$form}
{form_field form=$form field='label'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Label'}">
</div>
{/form_field}
{form_field form=$form field='company'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Company'}">
</div>
{/form_field}
{form_field form=$form field='title'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
{loop type="title" name="title1"}
<option value="{$ID}">{$LONG}</option>
{/loop}
</select>
</div>
{/form_field}
{form_field form=$form field='firstname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Firstname'}">
</div>
{/form_field}
{form_field form=$form field='lastname'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Lastname'}">
</div>
{/form_field}
{form_field form=$form field='address1'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Address'}">
</div>
<div class="form-group">
{form_field form=$form field='address2'}
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
<div class="form-group">
{form_field form=$form field='address3'}
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Additional address'}">
{/form_field}
</div>
{/form_field}
{form_field form=$form field='zipcode'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='Zip code'}">
</div>
{/form_field}
{form_field form=$form field='city'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<input type="text" id="{$label_attr.for}" name="{$name}" class="form-control" value="{$value}" title="{intl l="{$label}"}" placeholder="{intl l='City'}">
</div>
{/form_field}
{form_field form=$form field='country'}
<div class="form-group {if $error}has-error{/if}">
<label for="{$label_attr.for}" class="control-label">{intl l="{$label}"} : </label>
<select name="{$name}" id="{$label_attr.for}" class="form-control">
{loop type="country" name="country1"}
<option value="{$ID}">{$TITLE}</option>
{/loop}
</select>
</div>
{/form_field}
{/capture}
{include
file = "includes/generic-create-dialog.html"
dialog_id = "edit_address_dialog"
dialog_title = {intl l="Edit an address"}
dialog_body = {$smarty.capture.edit_address_dialog nofilter}
dialog_ok_label = {intl l="Edit this address"}
dialog_cancel_label = {intl l="Cancel"}
form_action = {url path='/admin/address/update'}
form_enctype = {form_enctype form=$form}
form_error_message = $form_error_message
}
{/form}
{* Default confirmation dialog *}
{capture "use_address_dialog"}
<input type="hidden" name="address_id" id="address_use_id" value="" />
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "use_address_dialog"
dialog_title = {intl l="Use address by default"}
dialog_message = {intl l="Do you really want to use this address by default ?"}
form_action = {url path='/admin/address/use'}
form_content = {$smarty.capture.use_address_dialog nofilter}
}
{* Delete confirmation dialog *}
{capture "delete_address_dialog"}
<input type="hidden" name="address_id" id="address_delete_id" value="" />
{/capture}
{include
file = "includes/generic-confirm-dialog.html"
dialog_id = "delete_address_dialog"
dialog_title = {intl l="Delete address"}
dialog_message = {intl l="Do you really want to delete this address ?"}
form_action = {url path='/admin/address/delete'}
form_content = {$smarty.capture.delete_dialog nofilter}
}
{/block}
{block name="javascript-initialization"}
{javascripts file='assets/js/main.js'}
<script src="{$asset_url}"></script>
{/javascripts}
{/block}