This repository was archived by the owner on Jul 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlivraison_pipelines.php
117 lines (101 loc) · 3.22 KB
/
livraison_pipelines.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
<?php
/**
* Utilisations de pipelines par Livraison
*
* @plugin Livraison
* @copyright 2015
* @author Cédric
* @licence GNU/GPL
* @package SPIP\Livraison\Pipelines
*/
if (!defined('_ECRIRE_INC_VERSION')) return;
function livraison_afficher_contenu_objet($flux){
if ($flux['args']['type']=='commande'
AND $id_commande = $flux['args']['id_objet']){
$adresse = recuperer_fond("prive/objets/contenu/commande-adresse_livraison",array('id_commande'=>$id_commande));
if ($p = strpos($flux['data'],"</table>")){
$flux['data'] = substr_replace($flux['data'],$adresse,$p+8,0);
}
else {
$flux['data'] .= $adresse;
}
}
return $flux;
}
/**
* Ajout de contenu sur certaines pages,
* notamment des formulaires de liaisons entre objets
*
* @pipeline affiche_milieu
* @param array $flux Données du pipeline
* @return array Données du pipeline
*/
function livraison_affiche_milieu($flux) {
$texte = "";
$e = trouver_objet_exec($flux['args']['exec']);
// livres sur les produits et offres abonnement
if (!$e['edition']
and $table = $e['table_objet_sql']
and $primary = $e['id_table_objet']
and $id = intval($flux['args'][$primary])) {
$objet = sql_fetsel("*",$table,"$primary=".$flux['args'][$primary]);
// si l'objet est livrable (pas immateriel) proposer le choix des modes de livraison
if (isset($objet['immateriel']) and !$objet['immateriel']){
$flux['data'] .= recuperer_fond('prive/squelettes/inclure/liens-livraisonmodes', array(
'table_source' => 'livraisonmodes',
'objet' => $e['type'],
'id_objet' => $flux['args'][$e['id_table_objet']]
));
}
}
if ($texte) {
if ($p=strpos($flux['data'],"<!--affiche_milieu-->"))
$flux['data'] = substr_replace($flux['data'],$texte,$p,0);
else
$flux['data'] .= $texte;
}
return $flux;
}
/**
* Renseigner les infos de facturation liee a une commande
* @param array $flux
* @return array mixed
*/
function livraison_bank_dsp2_renseigner_facturation($flux) {
if (isset($flux['args']['id_transaction'])
and $id_transaction = intval($flux['args']['id_transaction'])
and isset($flux['args']['id_commande'])
and $id_commande = intval($flux['args']['id_commande']) ) {
$commande = sql_fetsel("*", "spip_commandes", "id_commande=".intval($id_commande));
if ($commande) {
$quoi = '';
if (isset($commande['facturation_nom']) and $commande['facturation_nom']) {
$quoi = 'facturation';
}
elseif (isset($commande['livraison_nom']) and $commande['livraison_nom']) {
$quoi = 'livraison';
}
if ($quoi) {
if ($commande[$quoi.'_nom']) {
$flux['data']['nom'] = $commande[$quoi.'_nom'];
}
if ($commande[$quoi.'_adresse']) {
$flux['data']['adresse'] = $commande[$quoi.'_adresse'];
}
if ($commande[$quoi.'_societe']) {
$flux['data']['adresse'] = trim($commande[$quoi.'_societe'] . "\n" . $flux['data']['adresse']);
}
if ($commande[$quoi.'_adresse_cp']) {
$flux['data']['code_postal'] = $commande[$quoi.'_adresse_cp'];
}
if ($commande[$quoi.'_adresse_ville']) {
$flux['data']['ville'] = $commande[$quoi.'_adresse_ville'];
}
if ($commande[$quoi.'_adresse_pays']) {
$flux['data']['pays'] = $commande[$quoi.'_adresse_pays'];
}
}
}
}
return $flux;
}